Thomas Gratier
2021-05-31 20:50:39 UTC
Hello all,
Due to question at
https://gis.stackexchange.com/questions/398223/how-to-remap-gdal-options-from-string-version-to-a-dictionary-version
I've taken a look at code
When trying to use gdal.Warp from Python, most options are supported but
some seems to be missing
Although an approach with only `gdal.Warp(dest, origin,
options='-overwrite')` can work without code change,
the dict approach like below seems to be simpler from a Python perspective
kwargsoptions = {"overwrite": True} # particular key does not exist, just
for the explanation
gdal.Warp(dest, origin, **kwargsoptions)
Below are the command options I only found in gdalwarp command line but
absent in the WarpOptions (from doc
https://gdal.org/programs/gdalwarp.html#cmdoption-gdalwarp-r)
[-ct string]
[-novshiftgrid]
[-refine_gcps tolerance [minimum_gcps]]
[-ovr level|AUTO|AUTO-n|NONE]
[-srcalpha|-nosrcalpha]
[-q]
[-if format]*
[-overwrite]
[-oo NAME=VALUE]*
[-doo NAME=VALUE]*
-srcalpha is present but not it counterpart -nosrcalpha
In gdal.py code, there are references to resampling option not in the doc
e.g below excerpt
(from
https://github.com/OSGeo/gdal/blob/master/gdal/swig/python/osgeo/gdal.py#L588)
.
elif resampleAlg == GRIORA_Bilinear:
new_options += ['-rb']
elif resampleAlg == GRIORA_Cubic:
new_options += ['-rc']
elif resampleAlg == GRIORA_CubicSpline:
new_options += ['-rcs']
It may to need to be removed if looking at
https://gdal.org/programs/gdalwarp.html#cmdoption-gdalwarp-r
e.g (no -rcs, -rb or -rc options) except maybe for compatibility reason
I will try to make a PR. The main issue is more about naming for each
option.
I also don't know if command line and Python API "unsync" is due to
evolution, to intended API choices or other reasons.
I also only discuss here the gdal.Warp options but I suppose there are
maybe other Python tools ported from RFC 59
https://gdal.org/development/rfc/rfc59_utilities_as_a_library.html that may
have the same "unsync" issue.
Did not look at the moment
Regards
Thomas Gratier
Due to question at
https://gis.stackexchange.com/questions/398223/how-to-remap-gdal-options-from-string-version-to-a-dictionary-version
I've taken a look at code
When trying to use gdal.Warp from Python, most options are supported but
some seems to be missing
Although an approach with only `gdal.Warp(dest, origin,
options='-overwrite')` can work without code change,
the dict approach like below seems to be simpler from a Python perspective
kwargsoptions = {"overwrite": True} # particular key does not exist, just
for the explanation
gdal.Warp(dest, origin, **kwargsoptions)
Below are the command options I only found in gdalwarp command line but
absent in the WarpOptions (from doc
https://gdal.org/programs/gdalwarp.html#cmdoption-gdalwarp-r)
[-ct string]
[-novshiftgrid]
[-refine_gcps tolerance [minimum_gcps]]
[-ovr level|AUTO|AUTO-n|NONE]
[-srcalpha|-nosrcalpha]
[-q]
[-if format]*
[-overwrite]
[-oo NAME=VALUE]*
[-doo NAME=VALUE]*
-srcalpha is present but not it counterpart -nosrcalpha
In gdal.py code, there are references to resampling option not in the doc
e.g below excerpt
(from
https://github.com/OSGeo/gdal/blob/master/gdal/swig/python/osgeo/gdal.py#L588)
.
elif resampleAlg == GRIORA_Bilinear:
new_options += ['-rb']
elif resampleAlg == GRIORA_Cubic:
new_options += ['-rc']
elif resampleAlg == GRIORA_CubicSpline:
new_options += ['-rcs']
It may to need to be removed if looking at
https://gdal.org/programs/gdalwarp.html#cmdoption-gdalwarp-r
e.g (no -rcs, -rb or -rc options) except maybe for compatibility reason
I will try to make a PR. The main issue is more about naming for each
option.
I also don't know if command line and Python API "unsync" is due to
evolution, to intended API choices or other reasons.
I also only discuss here the gdal.Warp options but I suppose there are
maybe other Python tools ported from RFC 59
https://gdal.org/development/rfc/rfc59_utilities_as_a_library.html that may
have the same "unsync" issue.
Did not look at the moment
Regards
Thomas Gratier