I am trying to translate a .tif raster to an xyz one in Python
The code is this:
import sys
from osgeo import gdal
gdal.AllRegister()
driver = gdal.GetDriverByName('Local Disk')
dataset = gdal.Open('C:\Delft3D\Teste\GDAL\clc_raster.tif')
if dataset is None:
print "Could not!"
sys.exit(1)
gdal_translate -of XYZ dataset.tif C:\Delft3D\Teste\GDAL\clc_raster.tif.xyz
dataset = None
But I get the following error.
gdal_translate -of XYZ dataset.tif C:\Delft3D\Teste\GDAL\clc_raster2.xyz
^
SyntaxError: invalid syntax
I don't know why this error appears. I used the tips from convert geotiff to simple xyz elevation file?
D:\Delft3D\Teste\GDAL\clc_raster.tif.xyzas long as you execute the Python script in the same directory asdataset.tifand the directoryD:\Delft3D\Teste\GDAL\already exists. – Kersten Jan 25 '16 at 11:43