-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add 'gdal raster calc' #11850
base: master
Are you sure you want to change the base?
Add 'gdal raster calc' #11850
Conversation
9d69380
to
e07f29e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! Just a few comments below
* do not already have such a subscript. For example, "X" would be | ||
* replaced with "X[3]" but "X[1]" would be left untouched. | ||
*/ | ||
static std::string SetBandIndices(const std::string &origExpression, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My reading of the implementation is that if someone would use a variable "X" and "aX", and the intented substitution would be only for "X", then "aX" would also get substituted. No ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 49 should prevent this. But I'll look at whether I can make test_gdalalg_raster_calc_expression_rewriting
less convoluted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hopefully improved by ed4b07a
0763b4a
to
ed4b07a
Compare
What does this PR do?
Adds a
gdal raster calc
tool that provides much of the functionality ofgdal_calc.py
. Some differences withgdal_calc.py
:muparser
expression engine--input X=file.tif
rather than-X file.tif
--allBands
flag, the expression can either refer to all bands of a raster (--calc "X + 3"
) or a single band of a raster (--calc "X[1] + 3"
)--extent union
and--extent intersection
arguments are not supported, at least for now. I think these may best be handled by separate calls togdal raster mosaic/stack
andgdal raster calc
but could be persuaded otherwise without much difficultygdal_calc.py
are not supported (yet?)--input name=dsn[band(s)]
Feedback wanted!
What are related issues/pull requests?
#10067
#11209
#11656