[GIS] Performing raster map algebra in open source web GIS

map-algebraopen-source-giswcsweb-gis

Map algebra for raster is easy with ArcGIS Raster Calculator (or QGIS). I had thought this would be easy with web GIS servers such as GeoServer and MapServer plus OpenLayers etc. as well. What I want to achieve is to do simple things like dividing two images and generate a third, ratio image to be displayed in the webpage. I spent weeks to find a solution and it turns out to the pretty hard (for me).

I have tried a few things including:

  1. PostGIS raster. I think raster algebra isn't a problem here.

    But PostGIS raster is pretty difficult to load into GeoServer. There are many many questions repeatedly asked about how to load pgraster in GeoServer. See e.g. How to import GeoTIFF via postGIS into GeoServer?? , https://gis.stackexchange.com/questions/86006/publish-rasters-stored-in-postgresql-with-geoserver?, among others. Not a single answer here in GIS.SE or the GeoServer official website gives a complete list of steps that can be followed to work.
    Loading pgraster into MapServer has reported success, but with very slow performance. Both seem to require some tiling, and a one-liner command to import a raster to either server seems to be out of the question.

  2. GeoTIFF

    GeoTIFF is easy to load into GeoServer and MapServer. But what can we do with it? Without a PostGIS like SQL, I turned to and briefly searched using WCS to do map algebra, but didn't find much. Is WCS a viable path for this with current servers?

  3. Program it the hard way

    Somehow use AJAX to call a PHP page or write a WPS using GeoServer for importing images into PostGIS, doing the map algebra and then converting the result pgraster to a format (e.g. GeoTIFF) that can be easily loaded and displayed in GeoServer/MapServer.

  4. Of course, one can write code to read GeoTIFF's directly and do the map algebra without GIS support.

None of the above seems to be easy or reasonable to me considering the ease with which the same algebra can be done in Desktop GIS.

I was wondering if someone has had any experience doing Map Algebra in a web GIS environment, and can suggest a viable path?

I am interested in Open Source solutions (for political reasons inside my organization.) I am aware that ArcGIS Server can call python code of ArcGIS, but we don't have the license and the environment here is not favorable for acquiring one.

Best Answer

Using only open source software, you will almost certainly need to do some programming yourself. GDAL is the de facto open source raster I/O library, so you will probably be using it or one of its many wrappers. You could use Python (e.g. rasterio + numpy/scipy) or node.js, e.g. node-gdal (though beware it is currently synchronous/blocking). As for actually implementing it as a web service, I'm not sure what would be the best approach, but there is a related question here: Comparing different open source GIS servers?

If programming isn't your thing, you might take a look at FME Server. It's a commercial product but probably substantially cheaper than ArcGIS Server, and it has all sorts of raster calculation transformers, so I would be quite surprised if they could not accomplish what you need to do. You would not need to load the rasters into a database as it can read from just about any raster file format.

The server part would allow you to run the transformations (FME workspaces) on a server and use an API, e.g. the FME Server REST API, to initiate those transformations and access the results.

The main benefit is you would not need to do much if any programming to get the services up and running, just a little front-end coding to work with the API.

Related Question