|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.geotools.process.impl.AbstractProcess
org.geotools.process.raster.RasterToVectorProcess
public class RasterToVectorProcess
Vectorizes discrete regions of uniform value in the specified band of a GridCoverage2D object. Data are treated as double values regardless of the data type of the input grid coverage.
Example of use via the GeoTools process API
GridCoverage2D cov = ...
final Map<String, Object> params = new HashMap<String, Object>();
params.put(RasterToVectorFactory.RASTER.key, cov);
params.put(RasterToVectorFactory.BAND.key, Integer.valueOf(0));
params.put(RasterToVectorFactory.BOUNDS.key, env);
params.put(RasterToVectorFactory.OUTSIDE.key, Collections.singleton(0.0d));
params.put(RasterToVectorFactory.INSIDE_EDGES.key, Boolean.TRUE);
final Process r2v = Processors.createProcess(new NameImpl(ProcessFactory.GT_NAMESPACE, "RasterToVectorProcess"));
// run the process on a thread other than the event-dispatch thread
// (here we use SwingWorker to accomplish this)
SwingWorker worker = new SwingWorker<Map<String, Object>, Void>() {
protected Map<String, Object> doInBackground() throws Exception {
ProgressWindow pw = new ProgressWindow(null);
pw.setTitle("Vectorizing coverage");
return r2v.execute(params, pw);
}
protected void done() {
Map<String, Object> vectorizingResults = null;
try {
vectorizingResults = get();
} catch (Exception ignore) {}
if (vectorizingResults != null) {
FeatureCollection<SimpleFeatureType, SimpleFeature> fc =
(FeatureCollection<SimpleFeatureType, SimpleFeature>) vectorizingResults.get(
RasterToVectorFactory.RESULT_FEATURES.key);
// do something with features...
}
}
};
worker.execute();
Example of "manual" use with the static helper method:
GridCoverage2D cov = ...
int band = ...
Envelope bounds = ...
List<Double> outsideValues = ...
boolean insideEdges = ...
FeatureCollection<SimpleFeatureType,SimpleFeature> features =
RasterToVectorProcess.process(cov, band, bounds, outsideValues, insideEdges, null);
Field Summary |
---|
Fields inherited from class org.geotools.process.impl.AbstractProcess |
---|
factory |
Method Summary | |
---|---|
java.util.Map<java.lang.String,java.lang.Object> |
execute(java.util.Map<java.lang.String,java.lang.Object> input,
org.opengis.util.ProgressListener monitor)
Run the raster to vector process. |
static FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> |
process(GridCoverage2D cov,
int band,
org.opengis.geometry.Envelope bounds,
java.util.Collection<java.lang.Double> outsideValues,
boolean insideEdges,
org.opengis.util.ProgressListener monitor)
A static helper method that can be called directy to run the process. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public java.util.Map<java.lang.String,java.lang.Object> execute(java.util.Map<java.lang.String,java.lang.Object> input, org.opengis.util.ProgressListener monitor) throws ProcessException
Map
will contain a single object: the FeatureCollection
of vector polygons which can be retrieved as follows
FeatureCollection<SimpleFeatureType, SimpleFeature> features =
(FeatureCollection<SimpleFeatureType, SimpleFeature>) resultsMap.get(
RasterToVectorFactory.RESULT_FEATURES.key);
input
- a map of input parameters (see RasterToVectorFactory for details)monitor
- an optional ProgressListener
(may be null
)
Map
containing the vectorized features
ProcessException
public static FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> process(GridCoverage2D cov, int band, org.opengis.geometry.Envelope bounds, java.util.Collection<java.lang.Double> outsideValues, boolean insideEdges, org.opengis.util.ProgressListener monitor) throws ProcessException
The process interface is useful for advertising functionality to
dynamic applications, but for 'hands on' coding this method is much more
convenient than working via Process.execute(java.util.Map
cov
- the input coverageband
- the index of the band to be vectorizedbounds
- bounds of the area (in world coordinates) to vectorize; if null
the whole coverageoutside
- a collection of one or more values which represent 'outside' or no data
(may be null
or empty)insideEdges
- whether to vectorize inside edges (those separating grid regions
with non-outside values)monitor
- an optional ProgressListener (may be null
)
ProcessException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |