Apr 26, 2012
Following up last week’s post about smart halos, I wanted to share some ways of using compositing and filters together to achieve interesting effects.
As a starting point we use the smart halos map from the previous posting. You can find the features used in this post in the [compositing branch](https://github.com/mapnik/mapnik/tree/compositing) Mapnik 2.1 release. Just be aware that these new features are work-in-progress and some syntax might change in future releases.
Here is the original style:
Let’s look at water bodies and land. Solid fills are looking good, but what about adding some texture to the map? One way to add ‘texture’ is to use <pre><PolygonPatternSymbolizer/></pre>
Let’s grab one of the lovely watercolour patterns and apply to ‘water’ features.
Very nice so far, perhaps a bit flat. Now time to add some depth. One of the very useful image processing tools is the ability to apply various blurs. In this case I use ‘agg-stack-blur’ with both x/y radius’ set to 10 pixels:
<Style name="water-shadow" image-filters="agg-stack-blur(10,10)" comp-op="dst-over"> <Rule> <Filter>([HYC]=8)</Filter> <PolygonSymbolizer fill="lightblue" fill-opacity="0.4" smooth="0.7" transform="translate(0,0)" /> </Rule> </Style>
And lastly I add a bit of texture to the land fill to get that ‘paper’ feel to the final map :
I’m not sure the last step adds much to the cartography but it’s good to try different things. So go ahead and grab the latest source from [compositing branch](https://github.com/mapnik/mapnik/tree/compositing) Mapnik 2.1 and have fun!
Ooh, one more.. I really like ‘blur’ filters, they seem to be so versatile. Here is a water-floating-shadow style using a combination of ‘emboss’ and ‘agg-stack-blur’ filters, and also applying transform on the shadow symbolizer
transform="translate(10,10)"
Note, that while the water is floating in the air, all roads are on top of it - funky :)