0

I have a situation where I have to multiply sets of rasters by each other.
Currently I have subfolders of rasters on my machine and am looping through them and multiplying them with rasterio.

Is there a way to multiply rasters by each other within PostGIS?

Raterio converts rasters into numpy matrix so multiplication is possible but can PostGIS's representation of a raster be multiplied by another PostGIS raster representation?

Is ST_MapAlgebra the way to do this?

And would anyone have a simple example of such a process?

1 Answer 1

1

Try this;

SELECT ST_MapAlgebra(a.rast, b.rast, '[rast1] * [rast2]') rast
FROM rasttablea rasttableb b;

This works fine if your rasters are not tiled. If they are tiled it's a bit more complicated...

1
  • Thank you. Ill give this a go. Commented Jan 25, 2021 at 17:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.