[gdal-dev] gdal_calc.py improvments

Even Rouault even.rouault at spatialys.com
Wed Jun 24 15:05:35 PDT 2020

On jeudi 25 juin 2020 00:35:24 CEST Idan Miara wrote:
> Hi all,
> I've added some additions/improvements to gdal_calc.py
> https://github.com/talos-gis/gdalos/blob/master/src/gdalos/calc/gdal_calc.py
> 1. Alphalist now includes lower case letters.
> 2. added hideNoData option to ignore noDataValues
> 3. accept gdal datasets and pathlib.Path objects as alternative to string
> filenames of input rasters.
> 4. can work with input of different extents - either use a given extent or
> calculate an extent as a union or an intersection of the given rasters
> extents.
> 5. optionally verify equal Geotransform and SRS.
> 6. accept additional user_namespace to the global_namespace
> 7. option to return the output ds
> 8. allow to run without outF with MEM driver
> 9. accept a ColorTable input and apply to the output.
> 10. Accept multiple rasters with the same Alpha name to make a list of
> inputs. Then allow the use functions that operates on a vector of blocks,
> like "max" or "add" or
> https://github.com/talos-gis/gdalos/blob/master/src/gdalos/calc/gdalos_combi
> ne.py
> What do you think about these additions?

Sounds generally good, although I'm not completely sure about what all of them imply/mean

> Could you guide me what to do prior to creating a good PR for that?

I'd suggest perhaps to split into several PR so to make review easier. At least separate the 
more complex changes for more trivial ones.

> I guess some of my additions would need to be improved beforehand
> (Specifically #4, is there a better way to do it then to use VRTs? )

Using VRT for that sounds reasonable to me. You could probably do without it, but VRT is 
probably what will make the code clearer.

> and
> also maybe remove some of the dependencies in other functions, like
> GeoRectangle (for the input extent).

Not sure what GeoRectangle is, but yes you should try avoiding adding new dependencies.

> I also didn't create extensive tests for all that... (I'm not sure how time
> consuming this could be).

Isn't the general rule that 1/3 of the development time is implementing stuff, 1/3 adding 
tests and 1/3 documenting :-) ?

Tests for gdal_calc.py are in autotest/pyscripts/test_gdal_calc.py

Spatialys - Geospatial professional services
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20200625/ab426f3c/attachment-0001.html>

More information about the gdal-dev mailing list