Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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(
      tile.size()[0],
      tile.size()[0],
      )
s = mapnik.Style()
r = mapnik.Rule()

polygon_symbolizer = mapnik.PolygonSymbolizer(mapnik.Color('#f2eff9'))
r.symbols.append(polygon_symbolizer)
s.rules.append(r)

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')
m.layers.append(layer)

bbox = tile.bounds()
bbox = mapnik.Box2d(bbox[0], bbox[1], bbox[2], bbox[3])
m.zoom_to_box(bbox)
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.

Thanks.

share|improve this question
    
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
add comment

1 Answer 1

up vote 0 down vote accepted

The prj file has this:

GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.017453292519943295]]

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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