Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I do:

import os
from gdal import *

filename = 'c:/rast.jpg'
outputTif = 'c:/rastOut.tif'
os.system('gdal_translate filename outputTif')

but it returns "1".

gdal_translate doesn't save the image to disk. Is any additional parameter needed?

share|improve this question
1  
Are you sure you didn't mean something like os.system('gdal_translate ' + filename + ' ' + outputTif)? You are using literal 'filename' and 'outputTif', not the values of those variables. –  BradHards Apr 6 '13 at 8:51
1  
'it' returned 1 because os.system() encounter an error. If the command would be succefully completed you'd get a '0' –  nickves Apr 7 '13 at 1:38
add comment

1 Answer 1

up vote 2 down vote accepted

You forgot to describe GTiff driver and you do use string instead variable. Code below should work.

import os
from gdal import *

filename = 'c:/rast.jpg'
outputTif = 'c:/rastOut.tif'
os.system('gdal_translate -of GTiff %s %s'%(filename, outputTif))
share|improve this answer
2  
Geotiff is the default output type. It doesn't need to be specified. The rest of your answer is correct though. The problem is the OPs use of literal strings instead of the variables. –  Luke Apr 6 '13 at 10:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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