I have a huge amount of data in the form of CSV containing UTM coordinates as X
and Y
and an elevation value as Z
information. I need to convert these data into a DEM as GeoTIFF for further analysis. In this case, a huge amount means 16 m. lines, with one point in X
, Y
and Z
per line. The points are equally distributed, therefore an interpolation is not needed; each point just needs to be converted into a raster cell.
The original data came without separator, with fixed column widths. I already figured out how to convert the file syntax to use a separator instead of fixed widths and eliminate all space characters, using the stream text editor sed. From here on, normally my workflow would be to import the data into ArcGIS by creating a feature class from the X
, Y
and Z
data and as a second step, converting the point shapefile into a GeoTIFF, using the Point to Raster tool. However, the file I currently have is way too big for this process.
Instead of the above described workflow, I was looking for an efficient alternative and discovered GDAL. However, in gdal_translate
, the closest supported format I can find in the supported filetype list, is ASCII grid but no comma separated XYZ. Another difficulty is, that I have UTM coordinates, while most examples seem to use decimal degree coordinates. However, I need to stay within the UTM system (or at least, my output GeoTIFF needs to be in a UTM coordinate system).
So I am looking for a way to convert the CSV XYZ into a GeoTIFF, using GDAL, but so far wasn't able to find examples dealing with this exact problem. I would be very happy for some hints or even code examples.
Best Answer
You can do this using GDAL, it directly supports XYZ format. It doesn't matter if your coordinates are UTM, gdal_translate will output in the same coordinate system.
So to convert to GeoTIFF is as simple as:
Look at the GeoTIFF doc for output options (such as compression) and the gdal_translate doc for more usage info. In particular, you should specify what the coordinate system is with the
-a_srs
parameter.Comma/space separated and fixed column widths, with and without a header row are supported.
The only gotchas I'm aware of are:
The file has to be sorted correctly (by Y, then X).