I've got a Geoserver raster layer which represents a satellite image. I use the Geoserver WMS to display the raster in OpenLayers. I want to display only parts of the raster - those within a certain region.

Is it possible to send a parameter to the server (like a bbox, or a CQL expression), which will tell it to render only within a polygon?

Can i make any 'tweaks' in OpenLayers to accomplish this behavior? For vector layers I can use a cross-layer CQL filter in the WMS request, but what to do with a raster?

1 Answer 1


You can do this by adding a <Transformation> section to the SLD for your raster layer, e.g.:

  <ogc:Function name="gs:CropCoverage">
        <ogc:Function name="parameter">
        <ogc:Function name="parameter">
          <ogc:Literal>POLYGON ((-100 20, -60 20, -60 60, -100 60, -100 20))</ogc:Literal>

If the cropping polygon is to be specified by the user as part of the request, you can replace the cropShape constant above with SLD variable substitution.

  • I have this solution working only i have a colored bounding box outside of the clipped area. It is red, and I have some values that are red I am wondering if there is a value associated with the area within the extent outside of the clip shape that is getting assigned this color?
    – kflaw
    Nov 7, 2019 at 1:40

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.