Janes,

Glad it is working!

Note that you can pass a '--bbox' flag to nik2img that expects bounds in 
lat/long (and will transform them internally to your map srs). 

Dane


On Sep 15, 2010, at 8:43 PM, Janes Huff wrote:

> Thank you, Dana!
> Don't know wether to laugh or to cry now. <328.png> At least a silly fault of 
> mine. Now it works. 
> 
> CC or Janes
> 
> 2010/9/15 Dane Springmeyer <[email protected]>
> 
> On Sep 15, 2010, at 4:55 PM, Janes Huff wrote:
> 
>> Hi,
>> I tried some tests with mapnik using osm data (download brandenburg.osm from 
>> Geofabrik; cut out a smaller region with osm2pgsql: osm2pgsql --bbox 
>> 12.6247,52.2599,13.3848,52.5194 -m -d gis brandenburg.osm). All parts 
>> (postgis, mapnik, ...) seem to work fine.
>> 
>> I created the two files:
>> 
>> a) werder.py (origin code I took from here: 
>> http://trac.mapnik.org/wiki/XMLGettingStarted):
>> 
>> #!/usr/bin/env python
>> # -*- coding: utf-8 -*-
>> import mapnik
>> mapfile = 'werder.xml'
>> map_output = 'werder.png'
>> m = mapnik.Map(800, 600)
>> mapnik.load_map(m, mapfile)
>> bbox = mapnik.Envelope(mapnik.Coord(12.6247,52.2599), 
>> mapnik.Coord(13.3848,52.5194))
>> m.zoom_to_box(bbox) 
>> mapnik.render_to_file(m, map_output)
>> 
> Your Map is in mercator so you need to pass mercator coordinates to the 
> zoom_to_box function.
> 
> Here is an example of reprojecting long/lat coords into spherical mercator:
> 
> http://mapnik-utils.googlecode.com/svn/example_code/google_mercator_projection/world_mercator.py
> 
> You can also just render the werder.xml with nik2img.py which will 
> automatically zoom to the extents of your data (if set correctly, see below).
> 
>> 
>> 
>> b) werder.xml:
>> <?xml version="1.0" encoding="utf-8"?>
>> <!DOCTYPE Map>
>> <Map bgcolor="#ffffff" srs="+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 
>> +ellps=WGS84 +datum=WGS84 +units=m +no_defs">
> 
>> [...snip...]
> 
>>     
>>    <Layer name="strassen" status="on" srs="+proj=merc +lon_0=0 +k=1 +x_0=0 
>> +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs">
>>     <StyleName>strassen</StyleName>
>>     <Datasource>
>>       <Parameter name="type">postgis</Parameter>
>>       <Parameter name="password">my-very-secret-pw</Parameter>
>>       <Parameter name="host">localhost</Parameter>
>>       <Parameter name="port">5432</Parameter>
>>       <Parameter name="user">postgres</Parameter>
>>       <Parameter name="dbname">gis</Parameter>
>>       <Parameter name="table">planet_osm_line</Parameter>
>>       <Parameter name="estimate_extent">false</Parameter>
>>       <Parameter name="extent">12.6247,52.2599,13.3848,52.5194</Parameter>
>>     </Datasource>
>>    </Layer>
>> </Map>
>> 
> 
> Your layer is going to be in spherical mercator () as it was imported with 
> the -m flag of osm2pgsql, so that means your extent value must also be in 
> spherical mercator coordinates (not long/lat). An easy solution here is to 
> let PostGIS calculate the layer's extents automatically (just remove the 
> 'extent parameter' to trigger this).
> 
> 
> 
>> After execution I get no error message and the PNG-file I waited for. Well, 
>> but it's blank - sorry - it's background color is #fffff (or whatever color 
>> I setted). But no map features are shown.
>> I searched a lot by now, but couldn't figure out the mistake. Could you give 
>> me a hint, please?
>> 
>> 
>> Thank you,
>> CC
>> 
>> 
>> 
>> P.S.: 
>> 
>> OS: Kubuntu 10.4
>> Mapnik: 0.7
>> Postgresql: 8.4
>> 
>> Postgis: 1.5.1
>> osm2pgsql: 0.66.20090526
>> _______________________________________________
>> Mapnik-users mailing list
>> [email protected]
>> https://lists.berlios.de/mailman/listinfo/mapnik-users
> 
> 

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

Reply via email to