mapnik sotm 2007
TRANSCRIPT
Putting the map into OSM:
rendering geo-data with Mapnik
Artem Pavlenkomapnik.org
A brief history of (web)mapping
Good old 70s GIS
OGC WMS, WFS, W*S ...
Google Maps
[???]
Why did I like Google Maps?
No Java, no Flash, no ActiveX
No W*S
Lots of data
Good looking maps
APIs
What was the problem, then?
It is not free!
Data is subject to license and rendering software is proprietary
Searching for the solution
In the post GMap world we expect web mapping to be:
Fast
Highly interactive
And to have good cartography
At the time, none of the FOSS tools delivered these...
Mapnik
Mapnik is not ...
GIS
A map server, though you can hack one with Mapnik in no time
Attempt to implement all OGC specs in Java and bully the rest for not doing so
MapNick I'm not Nick ...
Mapnik is ...
About making beautiful maps
What I wanted to use myself
F/OSS
Cross platform Linux, Mac OS X, Win32
Written in modern c++
Easy to get started (Python bindings)
Flexible design
How do you make a map?
Making a map is easy
from mapnik import *
m = Map(800,600)
load_map(m,'/Users/artem/map.xml')
m.zoom_to_box(Envelope(-180,-90,180,90))
render_to_file(m,"world.jpg","jpeg")
What is *.xml?
Making a map is easy
Making a map is easy
Making a map is easy (almost)
lightgrey
white
MyStyle
Making a map is fun
from mapnik import *
m = Map(800,600,"+proj=latlong +datum=WGS84")
m.background = Color('steelblue')
s = Style()
r=Rule()
r.symbols.append(PolygonSymbolizer(Color('#f2eff9')))
r.symbols.append(LineSymbolizer(Color('rgb(50%,50%,50%)'),0.1))
s.rules.append(r)
m.append_style('My Style')
lyr = Layer('world')
lyr.datasource Shapefile(file='/opt/data/countries')
lyr.styles.append('My Style')
m.layers.append(lyr)
m.zoom_to_box(lyr.envelope())
render_to_file(m,'world.jpg', 'jpeg')
Made it!
More about styling...
Named styles, each layer can have 0...N style(s)
Order is important 'painter model'
0...N Styles -> 0...N Rules ->(Min/Max Scale Denominator, Filter, 0...N Symbolizer(s))
Filter is 'filter expression'
Filter expressions - DSEL
Syntax for filter expressions is very simple, you enclose variables (evaluated at runtime) in square brackets - [var]
Arithmetics: + , - , * , /
Comparison: = , , > , < , >= , 1000 and [area]