3

I have some grid data (2d array) that has some geospatial metadata associated with it. The bounds are in a jts polygon with WSG84 lon lat coordinates. The polygon is a rectangle, but is not axis aligned (not a bounding box).

I am trying to create a geotools CoordinateReferenceSystem object that describes this coverage. I want to use the CRS to reproject the coverage, but I also need to use the CRS as-is so skipping the CRS creation step is no good.

Boiled down: How do you go from a WSG84 polygon, dx, dy, nx, ny to a CoordinateReferenceSystem object that describes the grid using geotools?

Thanks in advance for the help

Brian Clements
  • 3,787
  • 1
  • 25
  • 26

2 Answers2

1

So you know the latlon rectangle which your coordinates fit into? Sounds like you could make an affine transform to transform your coordinates into lat/lon; and then carry on normally?

So process your geometry to "line up" with your rectangle first; they will then be in WGS84 and you can get on with life.

For background on affine transform check the docs:

If your data is actually a grid (as in a grid coverage) you can look at the image moasic code; it supports recording grids in all manner of orientations and stitches them into a seamless result.

Please note that for grids the process is reversed; rather than transform the data based on the request; the request is transformed to line up with the data (so it can sample the appropriate values out of the raster image).

Jody Garnett
  • 503
  • 3
  • 10
  • I was able to find the transform to reproject the grid into WGS84. I originally wanted to advertise the raw data's CRS, but that wasn't possible without more info. For my application, WGS84 is more useful anyway. – Brian Clements May 29 '11 at 14:47
0

If your coordinates are WGS86 you should use EPSG:4326 as the CRS. However from the sound of it your grid is in some other projection in which case you'll need to reproject the bounding rectangle to that projection and then create the grid in the correct projection.

If you don't know the projection that the grid data are in I suspect you are screwed.

Ian Turton
  • 10,018
  • 1
  • 28
  • 47