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

I extracted both nodes and ways from OpenStreetMap in PostgreSQL with Osmosis. I'm looking for all restaurants in a given area. The issue is that some of them are coded in OSM as nodes and others as ways.

How is it possible to have only one point when it is represented both as a node and a way?

The intuitive answer is to intersect the ways with the nodes. If a node is inside a way, they will both count as one. Otherwise, if there is only a node or only a way without nodes inside, it's fine.

The 'geometry' column in the 'ways' table does not contain information (it has something like a geometry, but all values are similar). Or maybe it is possible to use the 'nodes' table?

The fundamental question is: How is it possible to have a proper geometry column in PostgreSQL with Osmosis?

asked 14 Apr '14, 17:14

antonind's gravatar image

accept rate: 0%

edited 14 Apr '14, 18:29

iii's gravatar image


Alternatively, use osm2pgsql which builds geometries.

permanent link

answered 14 Apr '14, 20:00

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
accept rate: 23%

How do you do tag-filtering with osm2pgsql? I guess via a style file. If I'm not interested in some key, I just delete them from the style file?

(15 Apr '14, 10:02) antonind

You should be able to do that with lua tag transformations.

(15 Apr '14, 10:10) SomeoneElse ♦

But just deleting lines in the style file wouldn't do the thing?

(15 Apr '14, 10:38) antonind

Yes it would work; the only thing you can't do in the style file is saying "I want highway=A but not highway=B". You can only say that you want, or don't want, highway.

(16 Apr '14, 21:37) Frederik Ramm ♦

It worked perfectly by just removing some lines in the style file and using 'osm2pgsql -S --username myUsername --password --database myDB switzerland-latest.osm.pbf

(17 Apr '14, 13:33) antonind

The general understand is already ok.

For the postprocessing you might want to derive a own table/db as it's a custom procedure that depends on your own needs:

  • you want just the node holding all (maybe merged) metainformation
  • you might want to be able to determine the original OSM object (might be nessary for updates etc)

I guess you can do the processing just using PGSQL, but I would recommend e.g. a python script that:

  1. Creates a new table
  2. Add all nodes as lat/lon point geoms, maybe with additional fields for address, www, ...
  3. Find all restaurant closed ways (any maybe just building=*)
    1. Check if existing lat/lon points lay within this shape -> Flag shape as "processed"
    2. if not, calculate centeroid of that shape and add it in your point table

Sorry, I can't provide code, but maybe this will be helpful if you decide to do it the Python way:

permanent link

answered 14 Apr '14, 18:29

iii's gravatar image

accept rate: 10%

Follow this question

By Email:

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 14 Apr '14, 17:14

question was seen: 4,286 times

last updated: 17 Apr '14, 13:33

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