Friday, 20 May 2016

Is there a standard for the coordinates of pixels in georeferenced rasters ?


We are working with different raster datasets, and the pixel coordinates are either stored at the center of the pixel or at one corner. The information is usually provided in the metadata, but sometimes we need to guess and this post illustrates that it is not always easy to find.


As we also produce some layers, I was wondering if there was a standard rule and/or best practices to assign the coordinates for a pixel, ideally with a reference or with pro/cons.



Answer



This is a bit messy thing. You should read at least this GeoTIFF document


http://www.remotesensing.org/geotiff/spec/geotiff2.5.html#2.5.2.2 and some GDAL considerations


http://trac.osgeo.org/gdal/wiki/rfc33_gtiff_pixelispoint.


As a rule of thumb all rasters (aerial, satellite images) use pixel-is-area and measurement data like DEMs use pixel-is-point. But how it reflects to georeferencing and image extents is unfortunately not so simple. For GDAL the anchor point of the pixel is always at top-left corner of a pixel - if you store a new Ground Control Point (GPC) the given coordinates are always tied to the top-left corner of the corresponding pixel and it does matter if pixels are defined as areas or points. GDAL also reports the same extents for pixel-is-area and pixel-is-point images. It is up to user or software using GDAL to treat them differently if necessary.


The current OGC rule for georeferencing of coverages is to use a grid which is defined in the 437 pages long GML v.3.2.1 specification. That does make half a pixel difference in the location of origin for pixel-is-point and pixel-is-area because in case of area pixels the origin will be set to the middle of a pixel. The following quotation is from GML in JPEG2000 standard:




Note: GMLJP2 follows the definition of grids in GML 3.2.1 [OGC 07-036] clause 19.2.2: “When a grid point is used to represent a sample space (e.g. image pixel), the grid point represents the center of the sample space (see ISO 19123:2005, 8.2.2)”. This corresponds with the pixelInCell value of ImageCRS set to CellCenter as specified in ISO 19111. This can be interpreted as the origin of the RectifiedGrid is the centre point of the corner pixel.



For making things not to appear too simple, some programs like ERDAS imagine (AFAIK) follow internally the pixel-is-point schema as well as MapServer until the next-to-come version 7.0, with trying to change on-the-fly into the pixel-is-area schema. Reading about this: http://mapserver.org/fr/development/rfc/ms-rfc-107.html.


For best interoperability I would recommend to use pixel-is-area and GeoTIFFs for all natural rasters (aerial and satellite images, topographic maps). This is a well-known and thus reliable combination. If you play with DEMs and other measurement/sensor data and half a pixel shift can be meaningful be aware that they may be labeled as pixel-is-point and different programs may or may not introduce the half a pixel shifts.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...