Hi Torsten, Welcome to Mapnik!
On Apr 14, 2009, at 8:13 AM, Torsten Mohr wrote: > Hello, > > i downloaded mapnik-0.6.0 yesterday, compiling and installing (also > with > osm plugin) worked fine. > Great. But, the OSM plugin is new in 0.6.0 and not yet documented (http://trac.mapnik.org/ticket/289 ). The goal of the OSM plugin is to allow you to make maps directly from the osm xml data. However, the normal workflow is to import OSM data into postgresql and then render. This would use the 'postgis' Mapnik plugin. > I got some example python scripts and tried to render a map, but did > not > succeed. > > I downloaded a file "example.osm" and additionally exported a region > as > OpenStreetMap XML Data, Permalink: > > http://www.openstreetmap.org/?lat=47.7822&lon=9.1346&zoom=13&layers=B000FTF > See the tool osm2pgsql to import into postgis. > I also downloaded osm-styles.xml and osm.xml from trac.mapnik.org . > I'd like to render the map that i downloaded using python into a PNG > and > use the styles and rules defined in osm-styles.xml. > Right, these styles are designed to be used with postgis as a datasource, so I can't say whether they will work with the OSM plugin yet. See http://svn.mapnik.org/tags/release-0.6.0/plugins/input/osm/ test2.xml for a smaller example set of styles to try. > > My understanding is the following, can anybody please correct me when > i'm wrong? > > I need to create a mapnik.Map > > import mapnik > > m = mapnik.Map(600, 600, "+proj=latlong +datum=WGS84") > > And then i try to create Layers for all the Styles i'd like to use, > set the > datasource to the osm file that i downloaded, set the zoom and > render it. > > > st = ['world', 'world-1', 'builtup', 'places', 'text', 'water'] > ostyle = '/local/ftp/osm/osm-styles.xml' > osm = mapnik.Osm(file='/local/ftp/osm/bodensee.osm') > > for s in st: > lyr = mapnik.Layer(s, "+proj=latlong +datum=WGS84") > lyr.datasource = osm > lyr.styles.append(s) > m.layers.append(lyr) > > mapnik.load_map(m, ostyle) > > m.zoom_to_box(lyr.envelope()) > > mapnik.render_to_file(m, 'world.png', 'png') > Yes, thats generally the right approach although usually the association of Named Styles with Layers is handled in the mapnik xml styles that are read in with load_map(). In the snipped above you are assuming that the styles are attached to the map correctly, which is hard to say without seeing your xml. See: http://trac.mapnik.org/wiki/XMLGettingStarted > > But world.png is just empty. > Try: >>> m.zoom_all() > > Seems i'm doing something wrong, is it ok to use mapnik.load_map() to > load the styles? I did not find anything in the documentation. > > Generally you are on track, but I would first try getting rendering going with postgis and load_map(), then once that works try again with the OSM plugin to see if you can get it working with the osm styles. > Thanks for any hints, > Torsten. > Cheers, Dane _______________________________________________ Mapnik-users mailing list [email protected] https://lists.berlios.de/mailman/listinfo/mapnik-users

