VectorToRasterProcess fails for point data
------------------------------------------

                 Key: GEOT-3509
                 URL: http://jira.codehaus.org/browse/GEOT-3509
             Project: GeoTools
          Issue Type: Bug
    Affects Versions: 2.7.0
            Reporter: Michael Bedward
             Fix For: 2.7.1, 8-M0


Reported Mike O'Toole on the user list - rasterizing point features always 
results in a grid coverage where all cells are zero. The problem is that the 
AWT methods used to draw vectors into the backing image only make sense for 
polygons and lines.

The following code produced a correct result with Mike's data:
{code}
       GridCoverageFactory gcf =
CoverageFactoryFinder.getGridCoverageFactory(null);
       WritableRaster raster =
RasterFactory.createBandedRaster(DataBuffer.TYPE_FLOAT, numCols,
numRows, 1, new java.awt.Point(0, 0));
       GridCoverage2D cov = gcf.create("mycov", raster, new
ReferencedEnvelope(minx, maxx, miny, maxy, crs));

       GridGeometry2D gg = cov.getGridGeometry();
       SimpleFeatureIterator iter = collection.features();

       try {
           while (iter.hasNext()) {
               SimpleFeature feature = iter.next();
               Geometry p = (Geometry) feature.getDefaultGeometry();
               Float value = (Float) feature.getAttribute("value");

               Coordinate pcoord = p.getCoordinate();
               DirectPosition pos = new DirectPosition2D(pcoord.x, pcoord.y);

               GridCoordinates2D gc = gg.worldToGrid(pos);
               raster.setSample(gc.x, gc.y, 0, value);
           }
       } finally {
           iter.close();
       }
{code}

Put this into VectorToRasterProcess to deal with point data.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
Forrester Wave Report - Recovery time is now measured in hours and minutes
not days. Key insights are discussed in the 2010 Forrester Wave Report as
part of an in-depth evaluation of disaster recovery service providers.
Forrester found the best-in-class provider in terms of services and vision.
Read this report now!  http://p.sf.net/sfu/ibm-webcastpromo
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to