5. Compositing

TODO: find better example foreground / background image combinations

TODO: maybe extend OSM default style with a big single red dot marker, similar to CartoCSS example page

TODO: the TileMill project also has a nice visualization of the various composition operations

Mapnik supports all compisiting modes defined in the SVG standard, a few more are available when using the Agg render only.

By default the "src-over" compositing mode is used. A different mode can be set on the <Layer>, <Style> or symbolizer level.

TODO: explain level differences

TODO: add description lines to the table below

Table 35. Compositing modes
Mode Description

SVG standard modes

clear

color-burn

color-dodge

darken

difference

dst

dst-atop

dst-in

dst-out

dst-over

exclusion

hard-light

lighten

multiply

overlay

plus

screen

soft-light

src

src-atop

src-in

src-out

src-over

xor

AGG-only modes

color

contrast

divide

grain-extract

grain-merge

hue

invert

invert-rgb

linear-burn

linear-dodge

minus

saturation

value

All examples below basically use the same XML stylesheet, with just the comp-op attribute for the red dots layer changed.

Example 86. comp-op-example
<?xml version="1.0" encoding="utf-8"?>
<Map background-color='black'>
  <FileSource name="symbols">./symbols</FileSource>

  <Style name="countries">
    <Rule>
      <PolygonSymbolizer fill="green"/>
    </Rule>
  </Style>
  
  <Layer name="countries">
    <StyleName>countries</StyleName>
    <Datasource>
      <Parameter name="type">shape</Parameter>
      <Parameter name="file">data/ne_110m_admin_0_countries_lakes.shp</Parameter>
    </Datasource>
  </Layer>
  
  <Style name="style" comp-op="difference">
    <Rule>
      <PointSymbolizer allow-overlap="true" base="symbols" file="red/dot.svg"/>
    </Rule>
  </Style>  
  
  <Layer name="layer">
    <StyleName>style</StyleName>
    <Datasource>
      <Parameter name="type">csv</Parameter>
      <Parameter name="inline">
wkt
"POINT(1 1)"
      </Parameter>
    </Datasource>
  </Layer>
</Map>