NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

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%


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.

permanent link

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

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×263

question asked: 17 May '12, 23:18

question was seen: 3,014 times

last updated: 18 May '12, 00:25

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum