1

This question already has an answer here:

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])

marked as duplicate by Kersten, John Powell, Andre Silva, Chad Cooper, BradHards Jul 23 '16 at 2:54

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
    It sounds like python isn't accessing the folder where "src" (donnee1.grib2) is located. Did you try using a full path? – jbchurchill Jul 22 '16 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 Jul 22 '16 at 13:47
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'

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

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