I'm working with srtm dem files. They are ascii text files containing a table/grid of elevation values. At the top of the file is some metadata to locate the grid in lat/lon:
xllcorner -124.00041606132
yllcorner 48.999583599682
cellsize 0.00083333333333333
So initially I thought of the cells as points and assumed that the first value in the grid was the elevation for a point located at (xllcorner, yllcorner), and that the second value in the grid was the elevation at (xllcorner + cellsize, yllcorner). I then used this data to draw a 3d mesh with the mesh vertices corresponding to cells in the grid.
The resulting mesh looks correct but now I'm wondering if it's out by (cellsize / 2) in lat and lon…
When I started working with the file using Postgis Raster I discovered that it considers each cell as a polygon rather than a point. Rather than the first value representing the elevation for the point (xllcorner, yllcorner) it actually represents the the elevation for the polygon (xllcorner, yllcorner, xllcorner + cellsize, yllcorner + cellsize).
So, with that in mind, and seeing that I need to map each elevation to a point. Is it more accurate to say that the first value in the grid represents the elevation at (xllcorner, yllcorner) or at (xllcorner + cellsize / 2, yllcorner + cellsize / 2)?
Best Answer
Here's what the original NASA's SRTM document says (emphasis is mine):
What you have is an ASCII grid file. I've seen two types of these: one type defines the grid using
xllcorner
/yllcorner
, the other usingxllcenter
/yllcenter
, but both are essentially the same.SRTM height represents the (average) height of all points within the cell, which has a bounding box
(xllcorner, yllcorner, xllcorner + cellsize, yllcorner + cellsize)
. The center of that cell isxllcorner + cellsize/2, yllcorner + cellsize/2
. So, basically, the answer to your question is: use the center of the cell to represent the height point.I would also suggest running some TIN simplification algorithm on your mesh to reduce its size, that's what I did for my project.