Hi Michael,
One more question (and hopefully the last one):
After implementing your suggestion, I tried extending the GridCoverage with
custom categories, to add meaning to the data.
However, when I then export into GeoTiff, the image itself seems to
disappear. When I read in the GeoTiff, the RenderedImage is empty (0 kB).
Why does that happen?
Basically all I'd like to do is:
//Set data categories
Category[] catset = {
new Category("Floor", Color.BLACK, 0),
new Category("Wall", Color.WHITE, 1)
};
GridSampleDimension[] sampdims = {new GridSampleDimension("Map",
catset, null)};
GridCoverageFactory gcf =
CoverageFactoryFinder.getGridCoverageFactory(null);
GridCoverage2D cov = gcf.create("coverage", img, env, sampdims,
null, null);
The TiledImage has 1 band and all sample values are set to either 0 or 1.
I tried removing the coloring from the category, eg. new Category("Floor",
null, 0), to only assign a meaning. But the GeoTiff still has no
RenderedImage inside...
Any suggestions would be much appreciated.
Best regards,
Jan
On Wed, Dec 9, 2009 at 7:04 AM, Michael Bedward
<[email protected]>wrote:
> Hi Jan,
>
> GeoTools will take care of the CRS for you.
>
> For example, create a coverage with your 1000 x 1000 image and set its
> world bounds to be 0 - 100m in both directions...
>
> ReferencedEnvelope env = new ReferencedEnvelope(0, 100, 0, 100,
> null);
> GridCoverage2D cov = gcf.create("coverage", img, env);
>
> The coverage will automatically be given a simple AffineTransform to
> convert between grid and world coords, so you can do something like
> this...
>
> // get world coords of grid cell x=200, y=100
> DirectPosition dp = null;
> try {
> dp = cov.getGridGeometry().gridToWorld(new
> GridCoordinates2D(200, 100));
> } catch (TransformException ex) {
> ex.printStackTrace();
> }
> System.out.println("world coords: " + dp);
>
> Output is:
> world coords: DirectPosition2D[20.049999237060547,
> 89.94999694824219]
>
> These are the coords of the grid cell centre (with the usual fiddly
> round-off error).
>
> Note that as per the usual convention, image y increases from top to
> bottom while world y is the other way.
>
> Hope this helps,
> Michael
>
------------------------------------------------------------------------------
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users