MapQuest / MapQuest-Mapnik-Style

MapQuest Branded style for use with Mapnik and OSM
open.mapquest.co.uk
93 stars 25 forks source link

Issues generating MapQuest Open via Mapnik (am I doing this correctly?) #21

Closed mcoyote closed 10 years ago

mcoyote commented 10 years ago

Hi there,

((Sorry if this isn't the correct venue -- I couldn't find a mailing list or the like))

Hi there,

I'm new to mapnik though I've been using GeoServer, GeoTools, etc. for a long time. I'm currently trying to generate Mapquest Open-style maps using OSM data and have gotten pretty far with success, but I'm seeing results I don't understand and could use some advice.

Configuration:

What's up:

Here's the script I'm using to execute Mapnik, currently:

import mapnik stylesheet = 'mapquest-us.xml' image = 'mapquest_test_1.png' m = mapnik.Map(1000, 500) mapnik.load_map(m, stylesheet) m.zoom_to_box(mapnik.Box2d(-109.0603,36.9924,-102.0416,41.0024)) mapnik.render_to_file(m, image) print "rendered image to '%s'" % image

The results are definitely the state of Colorado, but there are clear level of detail differences with respect to what I see on openstreetmap.org. I suspect I'm invoking Mapnik incorrectly, so I thought it worthwhile to ask if anyone here has tried this with these versions of Mapnik, etc. and/or could point out what I'd missed.

Thank you for your time and please let me know if I may provide any additional information. mapquest_test_1

mcoyote commented 10 years ago

I think I figured it out.

The problem appears to be related to my osm2pgsql run at the start of my process. I had imported the osm data as espg:4326 (intentionally -- we can't work in spherical mercator) but left the mapquest open format configured as epsg:900913. I thought I had changed the style to epsg:4326 but there is another setting in the top-level XML file that also had to be changed. For some reason, when rendering via the python script the lat/lon based bbox made it through to the underlying queries and pulled the right data but (rightly) screwed the style's scale filters.

I've fixed the problem by switching the mapquest open style completely to epsg:4326, and now have the attached results (good).

Here's the working script, for reference (switching to center lat/lon is inconsequential):

import mapnik

; defines stylesheet_file = 'mapquest-us.xml' image_file = 'mapquest_test_1.png' img_x_in_pix = 1600 img_y_in_pix = 1200 center_lat=39.739167 center_lon=-104.984722 pad_in_deg=0.5

; build map_data map_data = mapnik.Map(img_x_in_pix, img_y_in_pix) mapnik.load_map(map_data, stylesheet_file)

; set box, zoom bbox = mapnik.Box2d(center_lon,center_lat,center_lon,center_lat) bbox.pad(pad_in_deg) map_data.zoom_to_box(bbox)

; zoom, render mapnik.render_to_file(map_data,image_file)

mapquest_test_1