2

I'm using gdal.warp to merge some files (see this former question of mine). I'm trying to use a dictionary instead of a long string to configure the options. However I'm having funny results with rasters of huge dimensions (25760x9427) instead of what I get when I use "string options" (4000x2001). However the call to gdal.warp does not raise any warning or error message. Still it seems clear that warp is not understanding some of the options I'm trying to pass to the function call. The problem is that the way options are names are different depending on how you give them, but this seems to be loosely documented. Or at least I could not find the one-to-one mapping between the "command line" options and their "key" counterpart.

My options (I mean those that work) are:

gdal_option = ("-t_srs EPSG:4326 "
               f" -tr {res} {res} -te {xmin} {ymax} {xmax} {ymin}"
               f" -co compress=LZW -overwrite ")

What I'm trying now is:

gdal_option = {"outputBoundsSRS": "EPSG:4326",
               "xRes": res,
               "yRes": res,
               "outputBounds": [xmin, ymax, xmax, ymin],
               "creationOptions": "COMPRESS=LZW",
               "options": "-overwrite"}

But it does not work. Any idea what is the name of the options that reproduce the command line string version?

Vince
  • 20,017
  • 15
  • 45
  • 64
Pythonist
  • 379
  • 4
  • 10
  • Options is "exclusive". See code in https://gdal.org/python/osgeo.gdal-pysrc.html#WarpOptions to confirm. It seems there is no "accessMode" key contrary to VectorTranslateOptions e.g https://gdal.org/python/osgeo.gdal-module.html#VectorTranslateOptions. Remove the "options": "-overwrite" to see if except -overwrite, it works – ThomasG77 May 31 '21 at 18:17
  • Ok I’ll try. But then what’s the way to give non key-value options such as overwrite? – Pythonist May 31 '21 at 18:25
  • Not sure it's possible with current code. You should ask on the mailing list https://lists.osgeo.org/mailman/listinfo/gdal-dev maybe – ThomasG77 May 31 '21 at 18:47
  • 1
    Already asked the question ;) – ThomasG77 May 31 '21 at 20:53
  • GDAL autotests can be used as examples, perhaps you can find something there https://github.com/OSGeo/gdal/blob/master/autotest/utilities/test_gdalwarp_lib.py. – user30184 Jun 01 '21 at 05:22
  • I saw the reply of the developers, and although I could not follow the technical details, I still do not see the big picture. If this option exists for the function, and can be passed in one of the valid formats enables by the library, why is not valid in other formats? It makes no sense to me, really. Anyway, I'll keep using the "string format" then. Thanks for your comments and insight! – Pythonist Jun 02 '21 at 08:16

0 Answers0