Hi,
i have a problem which looks trivial, but i have no idea what is going
wrong. I would like to create a GeoTiff or ArcGrid File and use several
colors for each number range. I read an ArcGrid file, apply a rotation and
afterwards the color specification should be taken into account to the
changed ArcGrid.
The values are ranged mostly from 0-1 as double. No Data values are marked
with 300.0. Writing the geotiiff and ArcGrid proceeds correctly but after
loading Geotiff file it shows me only black pixels and some strange value
ranges.
I would like to create a ArcGrid and Tiff file for example with the
categories listed in the code snippet.
Here is my code:
Category[] catset =
{
new Category("NoData", Color.BLACK, 300.0),
new Category("Zero", Color.WHITE, 0.0),
new Category("Low Precipitation", Color.GREEN,
NumberRange.create(0.01, 1)),
new Category("Medium Precipitation", Color.GREEN,
NumberRange.create(1.01, 2)),
new Category("High Precipitation", Color.GREEN,
NumberRange.create(2.01, 3))
};
// gsd
GridSampleDimension[] gsdPrec =
{
new GridSampleDimension("Precipitation", catset, SI.MILLIMETER)
};
// i read an ArcGrid raster file and apply a rotation.
agr = new ArcGridReader(new URL("file:/" + RASTERFILE), null);
GridCoverage2D gc2 = (GridCoverage2D)agr.read(null);
gc2 = rotateRaster(gc2);
Envelope env = gc2.getEnvelope2D();
// image settings
ImageLayout layout = new ImageLayout();
layout.setColorModel(gsdPrec[0].getColorModel());
RenderingHints hints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout);
// the renderedimage/gridcoverage should have the correct
// color specifications!
RenderedImage ri = gc2.getRenderedImage();
ri = FormatDescriptor.create(ri, DataBuffer.TYPE_FLOAT, hints);
// create the GridCoverageFactory
GridCoverageFactory fac = CoverageFactoryFinder.getGridCoverageFactory(null);
GridCoverage2D toWrite = fac.create("Precipitation", ri, env, gsdPrec,
null, hints);
// Write the files (code omitted)
this.writeRasterToTif(toWrite, "output.tif");
this.writeRasterToGrid(toWrite, "Ausgabe.txt");
Any ideas?
Thank you!
Matthias Hofmann
------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users