[gdal-dev] Problem calling gdalwarp from within python script

Simon Richard Proud srp at geo.ku.dk
Fri Jan 24 12:46:50 PST 2014

Does anyone have any other ideas as to what would be causing gdalwarp to output entire blank images when called from a python script?
I can get it to run using os.system and subprocess.call (using both shell=True and shell=False) but always just get a blank image (all pixels=0). This does not happen if I run exactly the same command from a terminal window.


Fra: gdal-dev-bounces at lists.osgeo.org [gdal-dev-bounces at lists.osgeo.org] på vegne af Sean Gillies [sean at mapbox.com]
Sendt: 20. januar 2014 11:56
Til: gdal-dev at lists.osgeo.org
Emne: Re: [gdal-dev] Problem calling gdalwarp from within python script

On 1/20/14, 1:57 AM, Even Rouault wrote:
> Selon Simon Richard Proud <srp at geo.ku.dk>:
>> Hi,
>> Unfortunately that produces a file not found error with filename "65535". If
>> I remove both arguments "-srcnodata" and "65535" then I go back to getting
>> the usage guidelines.
> You need to separate also the numerical values after -te and -tr
> ['gdalwarp','-q','-multi','-r', 'cubicspline','-t_srs', '+proj=geos +lon_0=0.0
> +h=35785831', '-te', '-5568748.2758', '-5568748.4774', '5568748.2758',
> '5568748.2758','-tr', '3000.40316582', '3000.40316582', '-srcnodata',
> '65535','TEST.tiff', 'TEST2.tiff']

The shlex.split() function is handy for turning strings that you would
have passed to os.system() into a list of args for subprocess functions.

     >>> import shlex
     >>> shlex.split('gdalwarp -q -multi -r cubicspline -te
-5568748.2758 -5568748.4774 5568748.2758 5568748.2758')
     ['gdalwarp', '-q', '-multi', '-r', 'cubicspline', '-te',
'-5568748.2758', '-5568748.4774', '5568748.2758', '5568748.2758']


Sean Gillies
sean at mapbox.com
gdal-dev mailing list
gdal-dev at lists.osgeo.org

More information about the gdal-dev mailing list