locationtech / geotrellis

GeoTrellis is a geographic data processing engine for high performance applications.
http://geotrellis.io
Other
1.34k stars 360 forks source link

GeoTiff reader fails for TIFFs georeferenced via ground control points #2455

Open jpolchlo opened 7 years ago

jpolchlo commented 7 years ago

A GeoTiff specifies a 2d array of values that are located on the globe according to some projection function. Most often, the projection function is specified as a tie point, a pixel size, and a transformation matrix. But a more explicit method for locating the pixel data on the globe is as a set of ground control points, or GCPs. These define a piecewise bilinear mapping from the pixel coordinates—ranging from (0, 0) to (image width, image height)—to world coordinates in some defined projection—lat/long, for example.

We've encountered this latter data format in the SENTINEL-1 SAR data files. Presently, GT fails to read these with a cryptic error message:

geotrellis.vector.ExtentRangeError: Invalid Extent: 
ymin must be less than ymax (ymin=35.501796671892045, ymax=33.99871125017203)

This error is due to the assumption that the georeferenced patch will be axis aligned to the world coordinate system, and that is not the case in the SENTINEL data. Consider the following image: GCPs for SENTINEL GeoTiff Here, we see the GCPs for the image that produced the earlier exception. These are points in lat/long that specify the shape and position of the patch that the pixel data covers. Note that these points are arbitrary in their orientation; the control point indicated in blue corresponds to the (0,0) pixel location, where subsequent image rows have increasing latitudes, in contrast to our customary case. However, we should expect that the transformation is "nice" (i.e., no two pixels cover the same world location).

It will be necessary to support this style of georeferencing if we intend to provide complete support for GeoTiffs. We can most likely leverage some of our existing reprojection code to accomplish this, but it is a non-trivial feature.

jpolchlo commented 7 years ago

There is a paucity of references describing how to use GCPs for this purpose. It's not clear if there are any restrictions on how these control points will be structured, or if there is a well-established mechanism for transforming pixel data in this fashion. Might be useful to look into GDAL's implementation. See https://trac.osgeo.org/gdal/changeset/39644, for example.