Tagging objects in OSM can sometimes be done as polygon or as point. For example ruins or museum

enter image description here

So far so good, but finding a specific object in a osm-dataset makes it necessary to look into the points AND into the polygons table.

For example: I want to display all museums in a city map. Some museums are tagged as points, some as polygon: enter image description here

I could import the centroids of the polygons into the point table. That will sometimes result in duplicates. Is there also a better way to solve that?

I'm using GeoPackage (ogr2ogr) or PostGIS (osm2pgsql) with QGIS 3.6


One way of getting around this is to use the center function in an Overpass query. (Documentation here.)

Normally, a query for museums gives us what you picture above: nodes as well as ways, depending on how the object exists in OSM. By appending center to your out statement, you'll get the centroid for the object.

Here is an example query:

out center;

And the output:

linden museum center

Even though the Linden Museum exists as a way, we get a node which represents its center. Upon converting to another GIS format, this will be included with the rest of the points.

A distinct advantage of this method is that the center function will also collapse relations to their centroids. It's possible that this could result in a centroid which is not located in any of the relation's parts, but does eliminate any potential duplicates.

You can try the query yourself right here.

  • 1
    Okay, this will give me exactly the result I expected. But unfortunately I use PBF and import it into a GPKG with ogr2ogr (I need not just need museum, I need nearly everything in the dataset!) Overpass is limited. – MAP May 12 '19 at 5:42
  • 1
    Ah! Well, it sounds like you need something like osmconvert, which includes the command --all-to-nodes. It performs similarly to the Overpass center function, but can apply to a PBF. I'd write up another solution, but I'm not as experienced with using osmconvert. You can find the relevant documentation here. – JoshC May 12 '19 at 12:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.