0

I'm trying to run gdalwarp from within a python script

 start = "gdalwarp -overwrite -ts 22 20 -r average -srcnodata 99 "
 input_file = filename[12:]
 output_file = "temp1.tif"
 print start + input_file + ' ' +output_file
 subprocess.call([r'%s %s output.tif' % (start, input_file)], shell=True )

Where filename changes iteratively (i'm batch processing and this is the first step). However when i run the script i get for example:

ERROR 4: `200301.h11v09.tif' not recognised as a supported file format.

But when i run the code on 200301.h11v09.tif in terminal it works perfectly. I feel like it's something to do with python string substitution but don't know enough to figure out myself now.

Any ideas?

asked Mar 25, 2014 at 20:41
2
  • Can you try it with a different filename. It might fail because of the two dots in your filename. Commented Mar 25, 2014 at 20:52
  • Makes no difference unfortunately same error with 200301h11v09.tif :( Commented Mar 25, 2014 at 20:54

1 Answer 1

1

Drop the brackets around the first argument to subprocess.call. It's designed to take either a the command string as a single argument, or as a list of arguments that will be separated by a space. Here you are supplying the whole argument in one, so give it as a string, not a list.

answered Mar 25, 2014 at 22:06

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.