3

I have a 1-band TIFF/raster file showing a value for each raster cell. I want to get those cell/pixel values of the TIFF extracted to a CSV file.

I guess there are two ways of doing this.

First, generate centroids of pixel/cell values of the tiff and then get the underlaying values of the raster, or Second, generate the values directly out of the TIFF (without the centroids first).

In the end I would like to have a CSV or tabular file format showing x, y and the values.

I want to use the QGIS console and a script or create a QGIS plugin. Any ideas?

1

1 Answer 1

3

Use either the gdal2xyz.py or gdal_translate programs included with GDAL to create a XYZ file. Basic usage is:

gdal2xyz.py -csv input.tif out1.csv
# or
gdal_translate -of XYZ -co COLUMN_SEPARATOR=, -co ADD_HEADER_LINE=YES input.tif out2.csv
1

Not the answer you're looking for? Browse other questions tagged or ask your own question.