Question

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

Was it helpful?

Solution

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).

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top