[OSM-talk] lat and lon in the db
Tom Hughes
tom at compton.nu
Wed Jul 27 09:17:41 BST 2011
On 27/07/11 09:08, kenneth gonsalves wrote:
> on querying the db, I get the lat and lon of a particular place as:
The db. Which db would that be exactly? Presumably one you have created
somehow from planet, but how exactly did you create it?
> lat 145921624 lon 864071554
>
> but the map shows the correct figures:
>
> lat 12.9954832 lon 77.6208684
>
> can anyone explain this?
Well I'm going to take a wild stab in the dark and guess that you have
used osm2pgsql to load a postgis database, and that you asked it to
create the database in the spherical mercator projection.
In which case those numbers are coordinates (in meters from the corner)
on a plane which has been projected using the spherical mercator projection.
So you need to reverse that projection and project back to EPSG 4326 if
you want lat/lon - there are postgis functions to do that.
Of course if your primary aim is to get lat/lon out of the database then
you'd be better off reloading it and telling osm2pgsql not to project
the data to spherical mercator.
Tom
--
Tom Hughes (tom at compton.nu)
http://compton.nu/
More information about the talk
mailing list