I think I have found the problem - I was using planet_osm_nodes lat and lon fields.  If I use the planet_osm_point way field, and extract the coordinates using ST_X() and ST_Y() all of the numbers match up.<br><br>You can see the factor of 100 difference if you do:<br>
      select id,lat,lon,astext(way) from planet_osm_nodes, planet_osm_point where id=osm_id and id=27496146;<br><br>This gives:<br>   mapnik=# select id,lon,lat,astext(way) from planet_osm_nodes, planet_osm_point where id=osm_id and id=27496146;<br>
       id    |    lon    |    lat    |                  astext                   <br>   ----------+-----------+-----------+-------------------------------------------<br>    27496146 | -13446488 | 730126793 | POINT(-134464.883471724 7301267.93936479)<br>
   (1 row)<br><br>   mapnik=# <br><br>Is this a bug in osm2pgsql, or a 'feature'?   Does anything use the lat/lon fields?<br><br>Graham.<br><br><div class="gmail_quote">2010/1/2 Graham Jones <span dir="ltr"><<a href="mailto:grahamjones139@googlemail.com">grahamjones139@googlemail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi,<br>I have a little Python application that populates a posgresql database using osm2pgsql, renders a map with mapnik and extracts information from the database to highlight points of interest.<br>
I am having a bit of trouble with working out what units the coordinates of nodes are in in the postgresql database and hope it is obvious to someone:<br>
<br>I am using the -m option, which I think means it will use a spherical mercator projection ("+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 +over").  I am using the same projection in my Python code.<br>

<br>What I find though is that when I use the mapnik.Projection() function to translate from lat/lon to spherical mercator y/x, my calculated values are a factor of 100 less than those in the postgresql database - If I just divide the postgresql database values by 100 and I plot them on my map they end up in the correct places.<br>

<br>It looks to me as though osm2pgsql must be storing the x/y values as integers in units of centimetres, but I thought that it was supposed to be in units of metres.<br><br>Is this the case, or have I got something wrong with my projections (If the answer is not obvious I will go and work out the maths myself to see what order of magnitude the xy values should be - I am not used to working in these coordinates).<br>

<br>Thanks,<br><br><br>Graham.<br clear="all"><font color="#888888"> <br>-- <br>Dr. Graham Jones<br>Hartlepool, UK<br>email: <a href="mailto:grahamjones139@gmail.com" target="_blank">grahamjones139@gmail.com</a><br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Dr. Graham Jones<br>Hartlepool, UK<br>email: <a href="mailto:grahamjones139@gmail.com">grahamjones139@gmail.com</a><br>