1

This question already has an answer here:

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?

marked as duplicate by ahmadhanb, nmtoken, Vince, whyzar, Hornbydd Jul 11 '17 at 13:49

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    What is your gdal version? You need GDAL > 2.1 to use gdal.Translate – pLumo Jul 11 '17 at 8:56
  • I used gdal.2.2.0 but the same problem is occuring – zakaria mouqcit Jul 11 '17 at 9:06
  • What does print gdal.VersionInfo() return? – Antonio Falciano Jul 11 '17 at 9:58
  • it returns this 1110200 – zakaria mouqcit Jul 11 '17 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. – Antonio Falciano Jul 11 '17 at 11:13

Browse other questions tagged or ask your own question.