1

I want to make a translation of a grib file to tif with gdal, I use the python script, and I have always error "the specified file not found '

import subprocess

src ="donnee1.grib2"
dst ="donnee2.tif"
subprocess.call(["gdal_Translate -of Gtiff -b 1",src,dst])
2
  • 1
    It sounds like python isn't accessing the folder where "src" (donnee1.grib2) is located. Did you try using a full path? Commented Jul 22, 2016 at 13:43
  • normally I have the files in the same directory as the python script,in this case I don't need to put all the way from directory, or not ???
    – user28253
    Commented Jul 22, 2016 at 13:47

1 Answer 1

1

I'm not entirely sure if this will fix the issue or not but you can try these commands at IDLE or your python command line of choice.

Note: I actually think you should look at the "possible duplicate" link and rethink your approach. It seems to make more sense than trying to call gdal from the command line. I can never get that to work except when using the OSgeo4W command line.

import os
os.getcwd()

Mine returns this ...
'C:\Windows\System32'\

This tells me that this is the folder Python is looking in for files.
In your case, the comment below indicates your system is looking there. Maybe try putting the file there or try using a complete path to the file ... something like

r"C:\FolderWithFileInIt\donnee2.tif"

so then ...

os.chdir(r"C:\dev")
os.getcwd()

'C:\dev'

2
  • I don't understand , I launched the command '''''import os os.getcwd()''''' and I had as a result : 'C:\\Python27'
    – user28253
    Commented Jul 22, 2016 at 14:37
  • what I should do after ????
    – user28253
    Commented Jul 22, 2016 at 14:39

Not the answer you're looking for? Browse other questions tagged or ask your own question.