I have been trying to use the subprocess module in python to perform the gdalwarp command.

To do so, I have done it like so

# use pixel size for GDAL WARP command
print('Pre warp')
warped_file = output_file + "_warped.tif"
subprocess.call(['gdalwarp', negative_file, warped_file, '-te', extent, '-tr', pixelsize])     
print('Post warp')

However, I keep getting this error

ERROR 6: Unknown option name '-te'
Usage: gdalwarp [--help-general] [--formats]
    [-s_srs srs_def] [-t_srs srs_def] [-to "NAME=VALUE"]* [-vshift | -novshift]
    [[-s_coord_epoch epoch] | [-t_coord_epoch epoch]]
    [-order n | -tps | -rpc | -geoloc] [-et err_threshold]
    [-refine_gcps tolerance [minimum_gcps]]
    [-te xmin ymin xmax ymax] [-tr xres yres] [-tap] [-ts width height]
    [-ovr level|AUTO|AUTO-n|NONE] [-wo "NAME=VALUE"] [-ot Byte/Int16/...] [-wt Byte/Int16]
    [-srcnodata "value [value...]"] [-dstnodata "value [value...]"] -dstalpha
    [-r resampling_method] [-wm memory_in_mb] [-multi] [-q]
    [-cutline datasource] [-cl layer] [-cwhere expression]
    [-csql statement] [-cblend dist_in_pixels] [-crop_to_cutline]
    [-if format]* [-of format] [-co "NAME=VALUE"]* [-overwrite]
    [-nomd] [-cvmd meta_conflict_value] [-setci] [-oo NAME=VALUE]*
    [-doo NAME=VALUE]*
    srcfile* dstfile

Available resampling methods:
    near (default), bilinear, cubic, cubicspline, lanczos, average, rms,
    mode,  max, min, med, Q1, Q3, sum.

Why is not recognising -te when its explicitly stated as an option??

  • 1
    Try making your extent arguments a single space separated string [etc..., '-te', ' '.join(map(str, extent)), etc...] or [etc..., '-te', ' '.join([f'{xy}' for xy in extent])), etc...] Assuming of course that your extent var is a simple list or tuple of coordinates [xmin, ymin, xmax, ymax].
    – user2856
    Commented Oct 3, 2022 at 0:26

1 Answer 1


A simple test with gdalwarp executable

gdalwarp -te
ERROR 6: Unknown option name '-te'

Another test

gdalwarp -te 1 2 3
ERROR 6: Unknown option name '-te'

And one more

gdalwarp -te 1 2 3 4
Usage: gdalwarp [--help-general] [--formats]

So it is possible to make the ERROR 6 to appear. by using -te option without giving the four terms xmin ymin xmax ymax. Check how you pass on the "extent" in your code subprocess.call(['gdalwarp', negative_file, warped_file, '-te', extent, '-tr', pixelsize])

  • I am passing four parameters, thats why I'm confused. gdalwarp negative_file warped_file -te 626025.04 231749.32 628094.65 234200.73 -tr 0.2816945692119213 0.28160941987363625 Commented Oct 2, 2022 at 12:56
  • Are you sure that you pass them right so that all four terms are kept together?
    – user30184
    Commented Oct 2, 2022 at 13:04
  • Anyway I do not believe that people should run gdalwarp with Python via subprocess because there is the Python library alternative. See usage examples from the GDAL autotests github.com/OSGeo/gdal/blob/master/autotest/utilities/…
    – user30184
    Commented Oct 2, 2022 at 13:28
  • It was out of curiosity I wanted to try it because I am getting this result with the Python library gis.stackexchange.com/questions/441920/… Commented Oct 2, 2022 at 13:33
  • I believe that this current question is more a generic Python question, but have you tried to pass '-te', 'xmin', 'ymin', 'xmax', 'ymax']? I apologize that I am not good at Python, usually just copying what I find from stackexchange.
    – user30184
    Commented Oct 2, 2022 at 13:51

Your Answer

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

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