I am using tm_wgs84_sans_antarctica.shp with mapnik to generate tiles. I am using the tiles with Google Maps Javascript API V3. But the projection is way off. Here is roughly what my code looks like:

import mapnik
m = mapnik.Map(
s = mapnik.Style()
r = mapnik.Rule()

polygon_symbolizer = mapnik.PolygonSymbolizer(mapnik.Color('#f2eff9'))

m.append_style('My Style',s)

ds = mapnik.Shapefile(file='tm_wgs84_sans_antarctica.shp')
layer = mapnik.Layer('world')
layer.datasource = ds
layer.styles.append('My Style')

bbox = tile.bounds()
bbox = mapnik.Box2d(bbox[0], bbox[1], bbox[2], bbox[3])
im = mapnik.Image( *tile.size() )
mapnik.render(m, im)

As you can see I am not setting any srs either in map or in layer. I tried different combination of projection strings without really understanding what they mean, but either got no map or wrongly projected map. Please let me know if any other information is required.


  • is there a prj file with the shp and dbf files? If so it should have the projection information in the prj file. It is in text format. – mhoran_psprep Mar 28 '12 at 21:57

The prj file has this:


Using srs +init=epsg:4326 which is defined as:

+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs

fixed the problem. Now the shape file gets rendered fine with google maps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.