This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

after osm2pgsql the osm_id is not the same id as in .osm file

0

Hi,

I'm trying to put my .osm file into postgres db using osm2pgsql. I've tried:

$ osm2pgsql -U postgres -d OSM ./my_country.osm

The problem is that the osm_id of the table "planet_osm_roads" on db is not the same id of the "way" tag on .osm file. For example, I took an id x of some way from the .osm file and then query the db by

"SELECT * FROM planet_osm_roads WHERE osm_id=x"

and I got nothing.

I want to get ways from db by thier ids on .osm file. After that I want to get all nodes of this way. There is any way to do that?

asked 17 May '12, 23:18

uriel's gravatar image

uriel
6111
accept rate: 0%


One Answer:

1

planet_osm_roads will only contain a selection of geometries (large streets and railways mostly). Use planet_osm_line to find smaller line geometries.

You will not find the way/node link in these tables however as they contain pre-computed geometries. If you really need node IDs then you have to look them up in the planet_osm_ways table (which you will only get with the --slim flag) but osm2pgsql is not optimised for that kind of query and will, for example, not even have all ways stored. If you really want to play with the "raw" OSM data then it is better to import with Osmosis.

answered 17 May '12, 23:24

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

Thanks. osmosis helped.

(18 May '12, 00:25) uriel

Source code available on GitHub .