1

In QGIS 3.14 , how can I export a raster (GeoTIFF) file as a XYZ formatted textfile, like;

Lon      Lat     z
123.456  34.567  23.45
123.447  34.588  20.22
...      ...     ...

Seems I have two options to export (save) raster files:

  1. Mouse 'Right-click' on the layer to activate the context menu and choose Export > Save As...
  2. From Raster menu, choose Translate (Convert Format) which is equivalent to the GDAL Translate in the Processing Toolbox.

The first option offers me lots of export formats - (below image) - but I cannot figure out which one returns simple ascii xyz textfiles.

enter image description here

With the second option, I can modify GDAL command call (to add -of XYZ) like I did in QGIS 2.18, but unfortunately QGIS 3.14 does not allow me to remove pre-existing -of GTiff.

2

The output type option is inferred from the extension of the filename you specify for output. If you change the name to end in .xyz then the -of option in the GDAL line will change and you can save in XYZ format:

enter image description here

which gave me:

3.125 2.83333333333333348 1
3.375 2.83333333333333348 4
3.625 2.83333333333333348 7
3.875 2.83333333333333348 10
3.125 2.5 2
3.375 2.5 5
3.625 2.5 8
3.875 2.5 11
3.125 2.16666666666666696 3
3.375 2.16666666666666696 6
3.625 2.16666666666666696 9
3.875 2.16666666666666696 12

for my test 3x4 raster. I didn't get any column headings, maybe additional options can add them if you need them.

3
  • Forgot to say the header is not important. Thanks!
    – Kazuhito
    Jul 13 '20 at 8:25
  • if you want one I think it's -co ADD_HEADER_LINE=YES
    – nmtoken
    Jul 13 '20 at 8:27
  • 1
    @nmtoken Yes, -co ADD_HEADER_LINE=YES gave me X Y Z as the topmost line. Thanks!
    – Kazuhito
    Jul 13 '20 at 8:45

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.