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

Sean Gillies sean at mapbox.com
Mon Jan 20 08:56:11 PST 2014


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


More information about the gdal-dev mailing list