[geotk] GridCoverageBuilde using Graphics2D

Martin Desruisseaux martin.desruisseaux at geomatys.fr
Fri Aug 2 10:00:46 PDT 2013

Hello Jacob

Le 02/08/13 17:58, Jacob Beeusaert a écrit :
> I am having some issues using Graphics2D to draw a GridCoverage using 
> the GridCoverageBuilder. I've written a Test for the behaviour. 
> Hopefully someone can help me understand what is going on.

I had a look to the test. I didn't checked deeply, but I would suggest 
to follow different steps:

> // Will use sample value in the range -10000 inclusive to 10000 
> exclusive.
> builder.setSampleRange(-10000, 10000);

I would suggest to avoid negative sample values, as they are not 
supported by IndexColorModel. While the library tries to workaround this 
limitation, there is more risk of unexpected results and it often 
consume more memory. I rather suggest:

builder.setSampleRange(1, 20000);

and replace:

> elevation.setLinearTransform(0.01, 0);
> elevation.addNodataValue("No data", 10000);


elevation.setLinearTransform(0.01, -500);
elevation.addNodataValue("No data", 0);

While not essential, using "0" for "no-data" also reduce the risk of 
unexpected results and allows a few optimization in the library.

On the following question:

> //How to define the grid value of the stuff we will draw? setColor??

I would not recommend to use ColorSpace or Graphics2D, since they are 
for drawing visual objects rather than computing geophysical values. 
Instead, I suggest:

WritableRaster raster = image.getRaster();
raster.setSample(x, y, 0, value);



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geotoolkit/attachments/20130802/d2b84183/attachment.html>

More information about the Geotoolkit mailing list