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:
GridCoverageFactory gcf =
WritableRaster raster =
numRows, 1, java.awt.Point(0, 0));
GridCoverage2D cov = gcf.create(
ReferencedEnvelope(minx, maxx, miny, maxy, crs));
GridGeometry2D gg = cov.getGridGeometry();
SimpleFeatureIterator iter = collection.features();
SimpleFeature feature = iter.next();
Geometry p = (Geometry) feature.getDefaultGeometry();
Coordinate pcoord = p.getCoordinate();
DirectPosition pos = DirectPosition2D(pcoord.x, pcoord.y);
GridCoordinates2D gc = gg.worldToGrid(pos);
raster.setSample(gc.x, gc.y, 0, value);
Put this into VectorToRasterProcess to deal with point data.
CodeHaus Comment From: mbedward - Time: Wed, 13 Apr 2011 01:22:59 -0500
Ended up using different logic to the code snippet - more compatible with the existing code. Added a test for point data.
Committed to 2.7.x branch (r36916) and trunk (r36917).