Hi, yes, I did, to no avail. What I really wanted was to do coverage.getEnvelope2D and just pass this to the method. NO idea why this does not work... Cheers M.
On 3/12/2010 11:54 PM, Michael Bedward wrote: > 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; > } > } > > > -- Martin Tomko Postdoctoral Research Assistant Geographic Information Systems Division Department of Geography University of Zurich - Irchel Winterthurerstr. 190 CH-8057 Zurich, Switzerland email: [email protected] site: http://www.geo.uzh.ch/~mtomko mob: +41-788 629 558 tel: +41-44-6355256 fax: +41-44-6356848 ------------------------------------------------------------------------------ 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
