0

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.

0

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:

> gdalinfo file.txt

If that works (i.e. without any ERRORS), then you can directly convert this with gdal_translate:

> gdal_translate -of GTiff -a_srs EPSG:???? file.txt file.tif

(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.

-1

Add your text file as "Add delimited text layer" under Layer -- Add Layer tab. Chose Custom delimiters and opt for "comma". in records and field option uncheck the box of "first record has field names" in geometry, definition chose points coordinates and in x field opt field_1, in y field_2 in geometry CRS chose the generated oneenter image description here

style as per your requirement. Go to layout manager under propeties tab and create a sample layout. under add items add map and generate your .tiff file

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.