I have a .tif file that contains all the elevation of a country.
How can I convert that to a CSV file that contains x,y,z values where x and y are the latitude longitude respectively and the z column is the elevation using QGIS?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
Go Raster->Conversion->Translate and then set the output to ASCII XYZ from the drop-down menu when you specify the output file.
An alternative ASCII format you may care to consider is the ESRI ASC format, which is smaller because it only lists the height (Z) and has a header which sets the raster origin and resolution. The Xand Y fields are now superfluous as a raster is a regular grid.
ASCII is a poor way of storing rasters though and you'd be better off with a GeoTif or JPEG.
EDIT: Working around a 'gotcha' in the QGIS translate dialog:
The Translate tool in QGIS has a major 'gotcha'. It doesn't automatically change the output format in the command line parameters, so changing the type in the output file doesn't automatically do anything other than change the extension of the output file name. The actual output encoding remains as the default GTiff. So, you must manually edit the command line parameters. To do this, set up the translation as normal and then click the little yellow pencil at the bottom of the dialog box (1). Then edit the command line so that the -of parameter reads
XYZ (in this case) instead of