Search code examples
geospatialspatialgeoserverwmsspatial-query

How can I filter/clip a raster provided by WMS - Geoserver


I'm trying to filter/clip a raster provided by a Web Map Service from Geoserver.

I dont want to clip based on a polygon; I want to filter based on a value such that all raster pixels below this value are black or transparent.

As far as I know I can not use cql_filter since its only for WFS Feature Requests and not for WMS Raster images.

Maybe you have an idea how to solve my question.


Solution

  • A WMS does not return you data, it returns a picture of your data.

    So there are two possibilities:

    1. You use a Web Coverage Service (WCS) request which will return you the actual data in your raster. Think of it as like a WFS for rasters. The GeoServer manual covers the mechanics of making a request and there is a request builder under Demos for you to experiment. I'm pretty sure this will only allow you to subset by rectangular areas, though your client is free to do more complex operations of the returned data.

    2. You can consider this a styling exercise in which case it should be possible to set up an SLD style that performs the operation that you need. You will need to use a spatial filter to clip the underlying raster and apply two rules depending on if it is true or false. You can even pass the polygon in as an environment variable from the request if you need.