1

I'm trying to clip a raster using gdal.Translate but i get this error message:

Traceback (most recent call last):
  File "C:/Users/Mouqsit/Desktop/test.py", line 6, in <module>
    ds = gdal.Translate("C:\\wamp\\www\\Donnees_CRTS\\irrisat_dessimination-smiej\\new.tif", ds, projWin = [681483.831264, 3558183.87652, 747933.831264, 3607833.87652])
AttributeError: 'module' object has no attribute 'Translate'

This is my code:

from osgeo import gdal
import sys ,os
output_dir='C:\\wamp\\www\\Donnees_CRTS\\irrisat_dessimination-smiej'
etp = os.path.join(output_dir,"L8_L8_ETpot_24_30m_2016_223.tif")
ds = gdal.Open(etp)
ds = gdal.Translate("C:\\wamp\\www\\Donnees_CRTS\\irrisat_dessimination-
smiej\\new.tif", ds, projWin = [681483.831264, 3558183.87652, 747933.831264, 
 3607833.87652])
ds = None

Have you any idea about what is happening right here?

5
  • 1
    What is your gdal version? You need GDAL > 2.1 to use gdal.Translate
    – pLumo
    Commented Jul 11, 2017 at 8:56
  • I used gdal.2.2.0 but the same problem is occuring Commented Jul 11, 2017 at 9:06
  • What does print gdal.VersionInfo() return? Commented Jul 11, 2017 at 9:58
  • it returns this 1110200 Commented Jul 11, 2017 at 10:45
  • 1110200 should be 1.11.2, if I'm not wrong... So you should update your Python GDAL bindings in order to make gdal.Translate work. Commented Jul 11, 2017 at 11:13

0

Browse other questions tagged or ask your own question.