geodesign / django-raster

Django-raster allows you to create tiled map services (TMS) and raster map algebra end points for web maps. It is Python-based, and requires GeoDjango with a PostGIS backend.
BSD 3-Clause "New" or "Revised" License
96 stars 39 forks source link

Using max() function in algebra #24

Closed PaulWagener closed 6 years ago

PaulWagener commented 6 years ago

Some functions require multiple arguments to be useful, such as max(), min(), sum() etc. But it seems the algebra parser is unable to handle formulas like max(a,b). I get a 400 bad request on such formula's. Is there a different syntax I should be using?

yellowcap commented 6 years ago

The min/max are using the numpy.amin and numpy.amax functions, not the numpy.minimum and numpy.maximum. So min/max is an array aggregate not a array comparison. The formula parser does not support multiple arguments in a function at the moment. So allowing min(a,b) requires a deeper refactoring.

However, you can achieve the result you want with the following formula:

a * (a > b) + b * (b > a)