I have downloaded the osm data and imported to my local database. There is a table called planet_osm_node and two columns lon and lat. As the description of the osm doc, latitude and longitude are stored as scaled integers with a scale factor of 1e7, so an integer latitude of -412870685 equates to -41.2870685.But I do this to the data, there is still difference with the real coordinate,for example the data is from (485231938,1295641506) to (48.5231938,129.5641506) while the real one is (116.389456757943,39.9061897544305). Is there a function or something to transform between these two forms? Please help and thank you very much. asked 22 Dec '16, 03:04 Connie Wang aseerel4c26 ♦ |
Ignore the information about scaled integers, it is not relevant to your use case. If you have imported with osm2pgsql then observe the following:
answered 22 Dec '16, 07:01 Frederik Ramm ♦ Thank you for your answering. I actually use the roads and nodes to partitioning the city into small areas. Then I need to reflect my order records into different area. So I need to know the right coordinate to confirm the scope of an area. I have tried the functions you mentioned above but I haven't gotten the format that I want.
(22 Dec '16, 07:36)
Connie Wang
|
Hi Connie, I have the same problem. Did you manage to get a solution? Best Regards, Varun. answered 02 Mar '17, 03:03 VarunDhr Yes,you can use the function of postgis,which is a opensource program of postgreSQL. Something like this:select id,ST_X(ST_AsText(st_transform(st_geomfromtext('POINT ('||lon/100||' '||lat/100||')',900913),4326))) as longi, ST_Y(ST_AsText(st_transform(st_geomfromtext('POINT ('||lon/100||' '||lat/100||')',900913),4326))) as lati from new_nodes
(02 Mar '17, 04:16)
Connie Wang
|
For anyone else who stumbles here looking for the answer. It depends on how the values were imported. My data was created by Nominatim, which simply converts lat/lon to an integer by multiplying by 10000000. This looks like the same case as the OP. answered 05 Mar, 13:00 neilireson |