[gdal-dev] gdal raster calc - a modulo operator (%)?
Javier Jimenez Shaw
j1 at jimenezshaw.com
Tue Oct 7 10:14:57 PDT 2025
Just for the record, "mod" of a floating point number should be properly
documented.
On Tue, 7 Oct 2025, 18:53 Daniel Baston via gdal-dev, <
gdal-dev at lists.osgeo.org> wrote:
> It's fairly straightforward to define functions in C++ and register them
> with muparser. You can see how we do this with "isnan" and "isnodata" here:
>
>
> https://github.com/OSGeo/gdal/blob/ca7a2d38893a8d6cdc03653b47712f4442d99d65/frmts/vrt/vrtexpression_muparser.cpp#L27
>
> I don't think we want too many custom functions, but adding "mod" seems
> like a good idea.
>
> Dan
>
> On Tue, Oct 7, 2025 at 12:30 PM Scott via gdal-dev <
> gdal-dev at lists.osgeo.org> wrote:
>
>> Greetings!
>>
>> I've been unable to find a modulo operator in CLI calc. It's not in the
>> muparser functions or appear to be in the forth-coming 3.12 C pixel
>> functions.
>>
>> This has been working with muparser, but it's messy every time you need
>> a simple modulo. pixel is real or int, div is int:
>>
>> rint(pixel) - (rint(rint(pixel) / div) * div)
>>
>> Am I missing something? If not, consider this a feature request! :)
>>
>> Thanks!
>> Scott
>>
>> --
>> www.postholer.com
>>
>> _______________________________________________
>> gdal-dev mailing list
>> gdal-dev at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/gdal-dev
>>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20251007/d016110d/attachment.htm>
More information about the gdal-dev
mailing list