3

I'm trying to generate map tiles using the mapnik's generate_tiles.py script, but the resulting tiles are overlapped.

Example

The tiles have the following directory structure: zoom_level/x_coordinate/y_coordinate.png.

Tiles 3/4/1.png , 3/4/2.png and 3/4/3.png have some countries shown twice (for example: Turkey and a part of Italy) like in the following image: overlapping tiles


Begin Edit

Here is how the tiles should look at the same zoom level as the previous image (zoom level: 3; these tiles were generated using MOBAC with the "OpenStreetMap Mapnik" Map source): OpenStreetMap Mapnik tiles generated with MOBAC

As you can see, in this case there aren't any tiles with overlapping content (or duplicate, if you prefer). Another strange thing is that only the tiles from the middle of the map (3.png and 4.png) look similar (cover approximately the same area). The other tiles (0.png , 1.png and 2.png) look totally different and I don't understand why!!!

Note: this is the first time I generate my own tiles so it's very likely that I'm doing a stupid mistake. It might be related to the projection I use (see below for the osm.xml).

End Edit


I tried setting the self.m.buffer_size to 0 (zero) (like this page says; anyway, that's regarding labels, which I don't need) in:

def render_tile(self, tile_uri, x, y, z):
    # ...

    render_size = 256
    self.m.resize(render_size, render_size)
    self.m.zoom_to_box(bbox)
    self.m.buffer_size = 128

    # Render image with default Agg renderer
    im = mapnik.Image(render_size, render_size)
    mapnik.render(self.m, im)
    im.save(tile_uri, 'png256')

Could it be a problem with the projection? Here are the important bits from my osm.xml file:

<Map bgcolor="#f2efe9" srs="+proj=latlong +datum=WGS84">

and

<Layer name="countries" status="on" srs="+proj=latlong +datum=WGS84">

Can someone help me? I already spent almost a week searching and documenting myself about this process and I got stuck here.

1 Answer 1

4

Slippy maps typically use the EPSG 3857 projection (another name for 900913, Google Web Mercator). In your stylesheet, change all occurrences of +proj=latlong +datum=WGS84 to +init=epsg:3857 to use the Spherical Mercator projection.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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