Hi there,

I'm working from http://trac.mapnik.org/wiki/XMLGettingStarted - so
far so good but I'd like to change the projection, with the ultimate
aim of rendering tiles that match up with Google Maps etc.  I've taken
the first example on that page, using the Mapping Hacks borders file,
and changed it slightly to work with the Thematic Mapping update, as
follows.

In the python code I've changed the envelope to what I believe are
Mercator coordinates that define a square Google-like map, and changed
the dimensions to be 600px square:

#!/usr/bin/env python
from mapnik import *
mapfile = 'world_styles.xml'
map_output = 'hello_world_using_xml_config.png'
m = Map(600, 600)
load_map(m, mapfile)
bbox = Envelope(Coord(-20037508.34, -20037508.34), Coord(20037508.34,
20037508.34))
m.zoom_to_box(bbox)
render_to_file(m, map_output)

And in the xml file, I've changed the Map's srs to match the one that
OpenStreetMap specifies in
http://svn.openstreetmap.org/applications/rendering/mapnik/osm.xml and
added a latlong srs to the world layer:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Map>
<Map bgcolor="white" srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0
+lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m [EMAIL PROTECTED] +no_defs
+over">
  <Style name="My Style">
    <Rule>
      <PolygonSymbolizer>
        <CssParameter name="fill">black</CssParameter>
      </PolygonSymbolizer>
      <LineSymbolizer>
        <CssParameter name="stroke">white</CssParameter>
        <CssParameter name="stroke-width">0.1</CssParameter>
      </LineSymbolizer>
    </Rule>
  </Style>
  <Layer name="world" srs="+proj=latlong +datum=WGS84 +over">
    <StyleName>My Style</StyleName>
      <Datasource>
        <Parameter name="type">shape</Parameter>
        <Parameter name="file">/home/tom/mapnik/TM_WORLD_BORDERS-0.2</Parameter>
      </Datasource>
  </Layer>
</Map>

The output of the code above seems to only show countries reliably in
the northeast, except for one or two others:
http://www.tom-carden.co.uk/hello_world_using_xml_config_merc.png

And I get almost the same issues with the original mapping hacks
"world_borders.shp" file instead:
http://www.tom-carden.co.uk/hello_world_using_xml_config_mh.png

However the output using the original projection settings on the wiki
(with modified colours) works just fine:
http://www.tom-carden.co.uk/hello_world_using_xml_config_merc.png

The comments on Thematic Mapping's blog suggest that I'll have an
issue reprojecting this data because of multi-polygons that cross the
date line: 
http://blog.thematicmapping.org/2008/03/world-borders-for-thematic-web-mapping.html

Can anyone suggest a way around this?

Many thanks,

Tom.
_______________________________________________
Mapnik-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/mapnik-users

Reply via email to