From: dementiev <dem...@gm...> - 2012-10-11 13:43:16
|
I need to colorized geometries from shapefiles and convert them to raster image (geotiff). I tried to use geotools's VectorToRasterProcess and ImageWorker ("d:\gis\tmp\32 27 25 w4.shp" is path to my test shapefile): URL url = new File("d:\\gis\\tmp\\32 27 25 w4.shp").toURI().toURL(); ShapefileDataStore ds = new ShapefileDataStore(url); FeatureSource fs = ds.getFeatureSource("32%2027%2025%20w4"); GridCoverage2D raster = VectorToRasterProcess.process(fs.getFeatures(), "ID", new Dimension(400, 400), fs.getBounds(),"test", null); ImageWorker imageWorker = new ImageWorker(raster.getRenderedImage()); imageWorker = imageWorker.rescaleToBytes(); imageWorker.makeColorTransparent(Color.BLACK); imageWorker.forceComponentColorModel(); raster = new GridCoverageFactory().create("one", imageWorker.getRenderedImage(), fs.getBounds()); GeoTiffWriter writer = new GeoTiffWriter(output); GeoTiffWriteParams params = new GeoTiffWriteParams(); ParameterValue<GeoToolsWriteParams> value = GeoTiffFormat.GEOTOOLS_WRITE_PARAMS.createValue(); value.setValue(params); writer.write(raster, new GeneralParameterValue[]{value}); writer.dispose(); The result geotiff is here <https://www.evernote.com/shard/s114/sh/8f1788d8-9dd9-4b59-bccc-af7ea79043cc/50b04e24cfe668fe6e38835e068a1ff3?noteKey=50b04e24cfe668fe6e38835e068a1ff3¬eGuid=8f1788d8-9dd9-4b59-bccc-af7ea79043cc> What is not right in my configuration of ImageWorker? Give, please, some advices. Regards, Dmitry -- View this message in context: http://osgeo-org.1560.n6.nabble.com/create-geotiff-from-shapefiles-tp5008043.html Sent from the geotools-gt2-users mailing list archive at Nabble.com. |
From: Michael B. <mic...@gm...> - 2012-10-12 00:48:41
|
Hi Dmitry, I wonder if this is actually a problem with the rasterizing process rather than ImageWorker. Does your shapefile include multipolygons with disjunct parts ? I'll need to check the code but it might not be allowing for this case. Michael On 12 October 2012 00:43, dementiev <dem...@gm...> wrote: > I need to colorized geometries from shapefiles and convert them to raster > image (geotiff). > > I tried to use geotools's VectorToRasterProcess and ImageWorker > ("d:\gis\tmp\32 27 25 w4.shp" is path to my test shapefile): > > URL url = new File("d:\\gis\\tmp\\32 27 25 w4.shp").toURI().toURL(); > ShapefileDataStore ds = new ShapefileDataStore(url); > FeatureSource fs = ds.getFeatureSource("32%2027%2025%20w4"); > > GridCoverage2D raster = VectorToRasterProcess.process(fs.getFeatures(), > "ID", new Dimension(400, 400), fs.getBounds(),"test", null); > > ImageWorker imageWorker = new ImageWorker(raster.getRenderedImage()); > imageWorker = imageWorker.rescaleToBytes(); > imageWorker.makeColorTransparent(Color.BLACK); > imageWorker.forceComponentColorModel(); > > raster = new GridCoverageFactory().create("one", > imageWorker.getRenderedImage(), fs.getBounds()); > > GeoTiffWriter writer = new GeoTiffWriter(output); > GeoTiffWriteParams params = new GeoTiffWriteParams(); > ParameterValue<GeoToolsWriteParams> value = > GeoTiffFormat.GEOTOOLS_WRITE_PARAMS.createValue(); > value.setValue(params); > writer.write(raster, new GeneralParameterValue[]{value}); > writer.dispose(); > > The result geotiff is here > <https://www.evernote.com/shard/s114/sh/8f1788d8-9dd9-4b59-bccc-af7ea79043cc/50b04e24cfe668fe6e38835e068a1ff3?noteKey=50b04e24cfe668fe6e38835e068a1ff3¬eGuid=8f1788d8-9dd9-4b59-bccc-af7ea79043cc> > > What is not right in my configuration of ImageWorker? Give, please, some > advices. > > Regards, Dmitry > > > > -- > View this message in context: http://osgeo-org.1560.n6.nabble.com/create-geotiff-from-shapefiles-tp5008043.html > Sent from the geotools-gt2-users mailing list archive at Nabble.com. > > ------------------------------------------------------------------------------ > Don't let slow site performance ruin your business. Deploy New Relic APM > Deploy New Relic app performance management and know exactly > what is happening inside your Ruby, Python, PHP, Java, and .NET app > Try New Relic at no cost today and get our sweet Data Nerd shirt too! > http://p.sf.net/sfu/newrelic-dev2dev > _______________________________________________ > GeoTools-GT2-Users mailing list > Geo...@li... > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users |
From: dementiev <dem...@gm...> - 2012-10-12 00:54:10
|
Michael, thank you for the answer. Yes, we have multipolygon with holes. But there are no disjunct parts. There is zip file with our started shapefile: https://dl.dropbox.com/u/2171206/32_27_25_w4.zip Dmitry -- View this message in context: http://osgeo-org.1560.n6.nabble.com/create-geotiff-from-shapefiles-tp5008043p5008174.html Sent from the geotools-gt2-users mailing list archive at Nabble.com. |
From: Michael B. <mic...@gm...> - 2012-10-12 01:14:44
|
I thought holes would be ok but looking at the unit tests there is nothing to confirm that. Also it seems that the process will have problems with disjunct parts (no tests for that either). So we might actually have two problems to fix. Thanks for the shapefile. I'll run some tests and, if it's easy to resolve the problems, commit the fixes later today (Sydney time). Michael On 12 October 2012 11:54, dementiev <dem...@gm...> wrote: > Michael, > thank you for the answer. > > Yes, we have multipolygon with holes. But there are no disjunct parts. > > There is zip file with our started shapefile: > https://dl.dropbox.com/u/2171206/32_27_25_w4.zip > > Dmitry > > > > -- > View this message in context: http://osgeo-org.1560.n6.nabble.com/create-geotiff-from-shapefiles-tp5008043p5008174.html > Sent from the geotools-gt2-users mailing list archive at Nabble.com. > > ------------------------------------------------------------------------------ > Don't let slow site performance ruin your business. Deploy New Relic APM > Deploy New Relic app performance management and know exactly > what is happening inside your Ruby, Python, PHP, Java, and .NET app > Try New Relic at no cost today and get our sweet Data Nerd shirt too! > http://p.sf.net/sfu/newrelic-dev2dev > _______________________________________________ > GeoTools-GT2-Users mailing list > Geo...@li... > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users |
From: dementiev <dem...@gm...> - 2012-10-12 01:19:17
|
Thank you very much! -- View this message in context: http://osgeo-org.1560.n6.nabble.com/create-geotiff-from-shapefiles-tp5008043p5008176.html Sent from the geotools-gt2-users mailing list archive at Nabble.com. |
From: Michael B. <mic...@gm...> - 2012-10-12 03:28:15
|
Hi Dmitry, The holes are indeed the problem. Unfortunately, the simple fix I tried broke existing unit tests and uncovered other weak spots in the process code. I'll have another look later today but if it turns out to be involved it will have to wait until the weekend before I can do more. Aside, it turns out that multi-polygons with disjunct parts are processed correctly. Michael |
From: Andrea A. <and...@ge...> - 2012-10-12 06:05:24
|
On Thu, Oct 11, 2012 at 3:43 PM, dementiev <dem...@gm...> wrote: > I need to colorized geometries from shapefiles and convert them to raster > image (geotiff). > How about creating a MapContent, paint onto a buffered image, turn that into a Coverage, and then save it to GeoTiff? The styles would allow you to control in detail how you colorize the various polygons. Cheers Andrea -- == Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information. == Ing. Andrea Aime @geowolf Technical Lead GeoSolutions S.A.S. Via Poggio alle Viti 1187 55054 Massarosa (LU) Italy phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339 8844549 http://www.geo-solutions.it http://twitter.com/geosolutions_it ------------------------------------------------------- |
From: Michael B. <mic...@gm...> - 2012-10-12 06:32:57
|
On 12 October 2012 17:05, Andrea Aime <and...@ge...> wrote: > How about creating a MapContent, paint onto a buffered image, turn that > into a Coverage, and then save it to GeoTiff? > The styles would allow you to control in detail how you colorize the various > polygons. > That's a nice bit of lateral thinking :) Michael |
From: dementiev <dem...@gm...> - 2012-10-13 12:44:44
|
We have done this with your approach. The result is great. Thank you for the advice! Dmitry. -- View this message in context: http://osgeo-org.1560.n6.nabble.com/create-geotiff-from-shapefiles-tp5008043p5008406.html Sent from the geotools-gt2-users mailing list archive at Nabble.com. |
From: Michael B. <mic...@gm...> - 2012-10-13 23:58:28
|
On 13 October 2012 23:44, dementiev <dem...@gm...> wrote: > We have done this with your approach. > > The result is great. > Good to hear. That was a great "cut to the chase" suggestion from Andrea ! Aside: this has also been useful because it has uncovered several problems with the current rasterizing process that I need to fix. Michael |
From: dementiev <dem...@gm...> - 2012-10-14 00:14:47
|
Thank you for the warm words and your help. -- View this message in context: http://osgeo-org.1560.n6.nabble.com/create-geotiff-from-shapefiles-tp5008043p5008462.html Sent from the geotools-gt2-users mailing list archive at Nabble.com. |
From: Andrea A. <and...@ge...> - 2012-10-14 19:58:24
|
On Sat, Oct 13, 2012 at 2:44 PM, dementiev <dem...@gm...> wrote: > We have done this with your approach. > > The result is great. > > Thank you for the advice! > Nice. Wondering, is that portion of your code simple enough that we could derive an example out of it? Is it something you can share? Cheers Andrea -- == Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information. == Ing. Andrea Aime @geowolf Technical Lead GeoSolutions S.A.S. Via Poggio alle Viti 1187 55054 Massarosa (LU) Italy phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339 8844549 http://www.geo-solutions.it http://twitter.com/geosolutions_it ------------------------------------------------------- |
From: dementiev <dem...@gm...> - 2012-10-14 22:30:09
|
Yep. Look at our geotiff generator class. <https://dl.dropbox.com/u/2171206/GeoTiffGenerator.java> (the same is in attach). GeoTiffGenerator.java <http://osgeo-org.1560.n6.nabble.com/file/n5008546/GeoTiffGenerator.java> You can call main method to generate geotiff. Regards, Dmitry. -- View this message in context: http://osgeo-org.1560.n6.nabble.com/create-geotiff-from-shapefiles-tp5008043p5008546.html Sent from the geotools-gt2-users mailing list archive at Nabble.com. |
From: David S. <dav...@ya...> - 2012-10-15 11:59:17
|
Dear All, Each polygon is made of a number of closed rings. What I have got now is each geometry object to represent a closed ring. The question is as follows: What is the simplest way to construct a multi-part polygon, given a list of geometry objects? With an array list, we can add new data into it. But, with several geometry objects, we can not simply add them. Regards. David |
From: Michael B. <mic...@gm...> - 2012-10-16 05:45:19
|
Dear David, I'm sorry for chasing you across lists but this is obviously a JTS question, not really anything to do with GeoTools per se. Also, you will have more response to your questions generally if you read the docs first. Repeatedly posting questions (for either project) that could instead be solved by just taking a few minutes to read the docs, will tend to result in everyone ignoring you which is not what we want here. The posting guide may be helpful: http://docs.geotools.org/latest/userguide/welcome/userlistguide.html Michael On 15 October 2012 22:58, David Shi <dav...@ya...> wrote: > Dear All, > > Each polygon is made of a number of closed rings. What I have got now is > each geometry object to represent a closed ring. > > The question is as follows: > > What is the simplest way to construct a multi-part polygon, given a list of > geometry objects? > > With an array list, we can add new data into it. But, with several geometry > objects, we can not simply add them. > > Regards. > > David > > ------------------------------------------------------------------------------ > Don't let slow site performance ruin your business. Deploy New Relic APM > Deploy New Relic app performance management and know exactly > what is happening inside your Ruby, Python, PHP, Java, and .NET app > Try New Relic at no cost today and get our sweet Data Nerd shirt too! > http://p.sf.net/sfu/newrelic-dev2dev > _______________________________________________ > GeoTools-GT2-Users mailing list > Geo...@li... > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users > |