[gdal-dev] ERROR 4 while using gdalwarp to mosaic and resample multiple ASTGTM zipped tiffs

Panagiotis Sismanidis panosis at noa.gr
Mon Jun 15 03:01:43 PDT 2020


I have prepared a python script that uses gdalwarp to mosaic and resample
ASTER DEM tiles, using as arguments the bounding box lat/lon coordinates
and the width and height of the output Gtiff. It works fine, except when I
use a quite large bbox (e.g. whole of Europe) where I get the gdal errors I
include below. If I split my bbox in two and iteratively run the script
there are no errors, all the tiffs are recognized without any issues, and
the process completes successfully. Do you know what can cause this weird
problem? Is it because of gdal or the OS?

The bbox coords (latS, lonW, latN, LonE) and the width and height that
gives me these errors are (29.94, -10.55, 61.18, 31.38), 4194 and 3125,

I use python 3.6.7, gdal 2.2.3 and Ubuntu 18.04.4.

Thank you in advance for your help!

    ERROR 4:
not recognized as a supported file format.
    ERROR 4:
not recognized as a supported file format.
    ERROR 4:
not recognized as a supported file format.
    ERROR 4:
not recognized as a supported file format.
    ERROR 4:
not recognized as a supported file format.
    Traceback (most recent call last):
      File "/home/USER/gdalwarp_ASTGTM_tiles_inside_bbox.py", line 127, in
        warp_ASTGTM_tiles(args.savename, args.bbox, args.width,
args.height, args.method)
      File "/home/USER/gdalwarp_ASTGTM_tiles_inside_bbox.py", line 107, in
        gdal.Warp(savename, DEM_tiles_bbox, options=warp_options)
      File "/usr/lib/python3/dist-packages/osgeo/gdal.py", line 580, in Warp
        return wrapper_GDALWarpDestName(destNameOrDestDS, srcDSTab, opts,
callback, callback_data)
      File "/usr/lib/python3/dist-packages/osgeo/gdal.py", line 3112, in
        return _gdal.wrapper_GDALWarpDestName(*args)
    SystemError: <built-in function wrapper_GDALWarpDestName> returned NULL
without setting an error

My function is the following:

def warp_ASTGTM_tiles(savename, bbox, width, height, resampling_method):

    bound_S = math.trunc(bbox[0])
    bound_W = math.trunc(bbox[1])
    bound_N = math.ceil(bbox[2])
    bound_E = math.ceil(bbox[3])

    ASTGTM_zips = Path(ASTGTM_DATADIR).glob("*.zip")

    ASTGTM_zips_bbox = []

    for zipf in ASTGTM_zips:
        if re.match(ASTGTM_REGX, zipf.name):
            tile_lat, tile_lon = get_tile_loc(zipf.name)
            if (tile_lat >= bound_S and tile_lat <= bound_N and
                tile_lon >= bound_W and tile_lon <= bound_E):

    if len(ASTGTM_zips_bbox) == 0:
        raise SystemExit("No tiles are available for given bbox")

    DEM_tiles_bbox = []

    for zipf in ASTGTM_zips_bbox:
        with zipfile.ZipFile(zipf, "r") as zp:
            dem = zipf.stem + "_dem.tif"

    warp_options = gdal.WarpOptions(
        outputBounds=(bbox[1], bbox[0], bbox[3], bbox[2]),

    gdal.Warp(savename, DEM_tiles_bbox, options=warp_options)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20200615/38e0c954/attachment.html>

More information about the gdal-dev mailing list