[OSM-dev] Using Mapnik to generate tiles from shapefiles

Artem Pavlenko artem at pavlenko.uklinux.net
Mon Jan 1 20:26:06 GMT 2007


Hi Nick,
Happy New Year to you, too!

> I would like to use Mapnik to generate tiles from shapefiles (generated
> from OpenStreetMap data).  The way I'm thinking of doing this is
> pre-preparing static tiles, either as a cron job, or on individual users'
> machines using an OSM at home like distributed approach, rather than as a live
> web service - much like the current OSM mapnik maps. Ny main interest is
> producing OS Landranger or Explorer like countryside maps using OSM and
> NASA SRTM contour data.
Yep, sounds good. You'll need to create a bunch of shape files - one per 
layer.  Shapefile can only have _one geometry type_ e.g Point, Polyline, 
Polygon etc. For large shapefiles I'd strongly suggest using shapeindex 
utility (part of Mapnik distribution) to create disk based spatial index. 

You might end up having something like that:

a_roads.shp
a_roads.shx
a_roads.dbf
a_roads.index

water_poly.shp
water_poly.shx
 .....

amenity_points.shp
...
and so on.  
>
> Is anyone able to give me the general procedure for producing tiles from
> shapefiles using Mapnik? I take it there'd be some sort of style file,
> which maps the records in the .dbf file to colours and fonts on the map.
> Preferred language is c++ as I know c++ but not python (as yet).
>

Mapnik is using 'named styles'  e.g you create a style and then you reference 
it by its name. Each style itself can have multiple Rules, Filters and 
Symbolizers. You can define all styles and datasources in one single xml 
file.  Good starting point would be to modify existing osm.xml to use 
shapefiles instead of postgresql. 

Have a look in $(mapnik_source)/demo/c++/rundemo.cpp for some usage info. 

Cheers,
Artem


> Thanks,
> Nick
>
>
>
>
>
> Send instant messages to your online friends http://uk.messenger.yahoo.com




More information about the dev mailing list