[OSM-dev] PostGIS & Mapnik problem
Colm McMullan
colm.mcmullan at gmail.com
Wed Jan 13 13:12:13 GMT 2010
Hi all,
I've been trying to put together my own rendering environment for kicks
recently and it's gone reasonably well however I've hit a snag when trying
to render with Mapnik from a PostGIS datasource.
My (simple) code is as follows:
#!/usr/bin/env python
import mapnik
mapfile = 'pimlico.xml'
map_output = 'pimlico.png'
m = mapnik.Map(600, 300)
mapnik.load_map(m, mapfile)
mapnik.render_to_file(m, map_output)
and the XML config it uses is:
<Map bgcolor="#ffffff" 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 +nadgrids=@null +no_defs -tl -r">
<Style name="line style 2">
<Rule>
<LineSymbolizer>
<CssParameter name="stroke">#000000</CssParameter>
<CssParameter name="stroke-width">3.0</CssParameter>
</LineSymbolizer>
</Rule>
</Style>
<Layer name="layer 4" srs="+proj=latlong +ellps=WGS84 +datum=WGS84
+no_defs" status="on">
<StyleName>line style 2</StyleName>
<Datasource>
<Parameter name="type">postgis</Parameter>
<Parameter name="host">localhost</Parameter>
<Parameter name="user">postgres</Parameter>
<Parameter name="dbname">gis</Parameter>
<Parameter name="estimate_extent">true</Parameter>
<Parameter name="table">planet_osm_roads</Parameter>
</Datasource>
</Layer>
</Map>
Unfortunately the output is simply a blank 'map' image with no roads drawn
at all. I turned on the postgres query log to see what's happening there
and this is the output I get:
2010-01-12 23:38:31 GMT LOG: statement: select f_geometry_column,srid,type
from geometry_columns where f_table_name='planet_osm_roads'
2010-01-12 23:38:31 GMT LOG: statement: select * from planet_osm_roads
limit 0
2010-01-12 23:38:31 GMT LOG: statement: select
xmin(ext),ymin(ext),xmax(ext),ymax(ext) from (select
estimated_extent('planet_osm_roads','way') as ext) as tmp
So it all seems fine but for some reason doesn't actually query the table to
fetch the data to render. Each of those queries succeeds when run
individually via psql and the extents query at the end returns a valid
result for the data that's in the table.
The planet_osm_roads contains a small subset of OSM data for a part of
London that I downloaded via the export function on the
openstreetmap.orgsite. I've checked the database and it's populated
correctly. In fact, I
used Qgis to load in the data to check it, then exported that as a
shapefile, changed the above XML to use the shapefile datasource instead and
it rendered the map correctly so there seems to be no problem with the
data...
So I'm a bit stumped, what am I missing? Has anyone got any suggestions?
Many thanks,
Colm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20100113/c7e67384/attachment.html>
More information about the dev
mailing list