I have many .txt files containing UTM XYZ coordinates of my study area. The content of each .txt file looks like this:
493932.0669,5426301.1910,0.468
497932.0669,5426301.1910,0.421
501932.0669,5426301.1910,0.341
505932.0669,5426301.1910,0.178
Aand it follows the general form of: UTM X, UTM Y, Z
. Each data point represents the center of a 4km by 4km grid.
What I want to do is to convert these .txt files into .tif files. I know how to do it in ArcGIS; however, it's a long process. I was wondering if there is a Python library (other than ArcPy) that can do this for me.
Best Answer
You can try using GDAL's XYZ driver to read these files. It may not always work for some files that aren't perfectly gridded, or are sorted in some unexpected way. To start with, if you have GDAL's tools installed in your PATH, try gdalinfo:
If that works (i.e. without any ERRORS), then you can directly convert this with gdal_translate:
(and replace the EPSG code with your UTM projection EPSG code, and obviously file names). There are Python interfaces to these tools, if you need them within a script.