javagisgeotoolsjtsogc

Geotools create CRS from polygon and dimensions


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


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