Oops... no, that's not the problem Martin. I'm afraid that's just me complicating things for you.
I've changed the type of the bounds parameter from Envelope2D to org.opengis.geometry.Envelope: http://jira.codehaus.org/browse/GEOT-2980 The example code reflects that change. If you are using a 2.6.2 the parameter type is Envelope2D. The example code would be as below. Sorry for the confusion. Also, have you tried passing null for the bounds which is interpreted as vectorize the whole coverage ? Michael public class RasterToVector { public static void main(String[] args) throws Exception { new RasterToVector().demo(); } private void demo() throws Exception { // beware annoying difference in parameter order and meaning between // Envelope2D and ReferencedEnvelope ! Envelope2D env = new ReferencedEnvelope(DefaultGeographicCRS.WGS84, 0.0, 0.0, 8.0, 8.0); GridCoverage2D cov = createChessboardCoverage(256, 256, 32, env); FeatureCollection<SimpleFeatureType, SimpleFeature> fc = RasterToVectorProcess.process(cov, 0, env, Collections.singletonList(0.0d), null); MapContext map = new DefaultMapContext(); map.setTitle("raster to vector conversion"); Style style = SLD.createPolygonStyle(Color.BLUE, Color.CYAN, 1.0f); map.addLayer(fc, style); JMapFrame.showMap(map); } private GridCoverage2D createChessboardCoverage(int imgWidth, int imgHeight, int squareWidth, Envelope2D env) { GridCoverageFactory factory = CoverageFactoryFinder.getGridCoverageFactory(null); GridCoverage2D cov = factory.create("chessboard", createChessboardImage(imgWidth, imgHeight, squareWidth), env); return cov; } private RenderedImage createChessboardImage(int imgWidth, int imgHeight, int squareWidth) { BufferedImage img = new BufferedImage(imgWidth, imgHeight, BufferedImage.TYPE_BYTE_BINARY); WritableRaster raster = img.getRaster(); for (int y = 0; y < imgHeight; y++) { boolean oddRow = (y / squareWidth) % 2 == 1; for (int x = 0; x < imgWidth; x++) { boolean oddCol = (x / squareWidth) % 2 == 1; raster.setSample(x, y, 0, (oddCol == oddRow ? 1 : 0)); } } return img; } } ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Geotools-gt2-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
