1

I am trying to get started with GDAL on a windows machine using Python2.7. I have tried commands such as:

gdalinfo RasterFileName.TIF and gdal_translate.py -projwin ulx uly lrx lry -of GTiff input.TIF output.TIF

and they run without producing any results. What am I missing that makes these not to work.

For example, I am doing the gdal_translate as follows:

    import os
    infile = path+'InFileName.TIF'
    outfile = path+'OUTFileName.TIF'
    string ='gdal_translate -projwin %.0f %.0f %.0f %.0f -of GTiff %s %s' %(ulx,uly,lrx,lry,infile,outfile)
    os.system(string)

Many thanks

RyanKDalton
  • 23,068
  • 17
  • 110
  • 178
user2757128
  • 523
  • 2
  • 6
  • 9

1 Answers1

0

On Windows, you have to load the GDAL environment variable to make the command-line utilities to work. With MS4W, for example, you have to run setenv.bat. This set some GDAL environment variables. I suspect your script doesn't have those variable set. You could probably run it before your script.