Color blending and compositing implemented for GeoServer 2.7


Dear Readers,

in this post we want to introduce a new mapping ability available in the GeoServer 2.7.x series: color blending and compositing.

The notion of color blending and compositing has been borrowed from the SVG specification, and it’s commonly available in image manipulation programs such as Gimp/Photoshop, and has been available, with different types of limitations, in open source GIS software MapServer, QGis and Mapnik.

GeoServer own implementation is sort of a sum of the above software abilities, in that it provides both Porter-Duff compositing, useful for masking, color blending, great to more naturally blend multiple colored levels, and base compositing layers, very important to get accurate control of how masking and blending are performed, especially in a WMS setting where the client can decide how layers are going to be stacked up.

As an example of masking via Porter-Duff compositing, let’s pick two images, the first is know as the destination, the second as the source (the source is painted on top of the destination):

Destination Source

The two images can be used to mask each other using destination-in and source-in masking:

Destination-in Source-in
../../_images/blend2-destination-in.png ../../_images/blend2-source-in.png

Color blending is instead quite useful to naturally blend DEM colors with polygon fills above them, for example, given the following source and destination, the multiply color blend results in a nice looking blended map:

Destination Source Multiply
../../_images/map.png ../../_images/bkg.png ../../_images/blend1-multiply.png

Now, both masking and blending results are quite sensitive to the destination being blended onto. Normally a layer will blend with the sum of the previously painted layers, making the result rather sensitive to how the WMS request issued by the client, who is in control of how layers are being stacked up.

To have better control one or more FeatureTypeStyle can be marked as a composite base, that is, a destination on wich the subsequent layers will be blended against, and that will be blended against the layers before it only as the last step in the map drawing.

Let’s see how this can be used to generate interesting map effects. We have the usual states map, and a natural earth raster layer. We would like to get a “line inside polygon” effect for the states, and then combine the result on top of the natural earth raster layer. The first step is easily achieved by creating a black thick stroke which will be used as the mask against the states layer:

Source-in compositing


Now, what happens if now we stack the natural raster layer, states, and the black mask? The states layer will be painted on top of the raster, and the result will be used as the destination for the masking, resulting in this:


Not exactly what we wanted… to make sure we get the right result, the topp:states layer need to be marked as a compositing-base, this will make sure the compositing happens between states and the mask, and only after that the result will be painted on top of the raster layer, resulting in the following:


You can look at the user guide for a full set of composite/blending examples, and the SLD for the above map.

We would like to thank Cleveland Metroparks for funding this work which was carried out as part of  GeoSolutions Enterprise Support Services Plan.

The GeoSolutions team,



  1. # Martin Davis

    Very nice. Would it be possible to get the tint bands to fade out towards the inside of the polygons?

  2. # Andrea Aime

    Hi Martin,
    what you are looking for is known as “shapeburts fill” (which, in your case, would fade to fully transparent towards the center of the polygon).
    We don’t have support for it GeoTools/GeoServer yet, but we could implement it by adding some extra vendor options to polygon symbolizer. And yep, once implemented it would play well with compositing.

Leave a Reply