3

I am trying to process elevation data from the AW3D30 dataset with Python. I read GeoTIFF files directly without any external libraries like GDAL. Elevation data (raster type) is specified as PixelIsArea.

As I would like to interpolate the elevation between existing points, I would like to know, what are the geocoordinates of the existing points. The accompanying description file (HDR) says they start at (0.5,0.5), but I've seen some references elsewhere (geotiff.maptools.org) saying that PixelIsArea point should be interpreted as (-0.5,-0.5).

To illustrate - if in the following picture point C1 is what I read from the file and the raster type is PixelIsArea, which are the correct geocoordinates of this point: C2 or C3? PixelIsArea

2

The geotiff spec on geotiff.maptools.org states if you want to display a PixelIsPoint raster, the origin is shifted to (-0.5, -0.5). The "point" remains at (0,0), it is just displayed as the centre of the pixel.

If a point-pixel image were to be displayed on a display device with pixel cells having the same size as the raster spacing, then the upper-left corner of the displayed image would be located in raster space at (-0.5, -0.5).

A PixelIsArea raster pixel centroid is therefore (0.5,0.5), so your point "C2" is correct.

Your demo picture has the origin 0,0 at the lower left, so I assume you're talking about coordinate space (X, Y) not raster space (col, row). Note the geotiff spec refers only to raster space (col, row).

this spec shall not refer to "X" and "Y" raster coordinates, but rather to raster space "J" (row) and "I" (column) coordinate variables instead, as defined in section 2.5.2.2.

Don't forget the values in the ModelTiepointTag are the coordinates of the upper left of the raster (0,0 in raster space) so convert that to coordinate space (calculate the lower left of raster or for each pixel) before adding (0.5,0.5) to calculate the coordinates of the centroid of a PixelIsArea pixel. If you don't, and are calculating from the upper left of the pixel, use (0.5,-0.5).

  • Thanks for the additional clarification. I forgot to mention I read the data (rows) from GeoTIFF in reverse so that I have (0,0) in lower left corner. That's because I also read other formats (DTED and BIL from SRTM) and arrange them the same way. More about this on SRTM1-Global. – Diamond Dutch Jan 27 at 10:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.