JOSM filter for multipolygon only

Hi,

I need to separate points, lines and multipolygon for a small project. I’m mostly interested in buildings with closed multipolygon.

I’ve imported all relevant objects into JOSM using Overpass Turbo exports. Now I’m having a hard time finding the right filter to select lines only to delete or save them separately.

Any idea how the syntax of a filter in JOSM would look like?
And is there a possibility to filter this in Overpass Turbo as well?

Thank you!

Best,
Clemens

1 Like

Part of the answer (but likely not the complete answer) might be to look for (if: is_closed() == 1 ). Here’s an example.

1 Like

I’m unsure whether it’s possible to filter by closed ways in JOSM using the standard or regex syntaxes, but you can achieve it using the MapCSS selector syntax. Here’s an example copying @SomeoneElse’s Overpass QL:

way["leisure"="track"]:closed

And, certainly, the inverse filter parameter must be “on”.

Would something as simple as:

relation["type"="multipolygon"]; – Overpass

or

type:relation and type=multipolygon – JOSM query

do the trick? Or is there something more that you need the filter to do?

1 Like

Thanks, but I’m not getting good results.

Maybe another approach: how can I get buildings only? I need power plants and substation facilities without the related ways and points.

When searching/selecting/filtering in JOSM (i.e. via ctrl+f) you just enter closed as a string. That will mark all closed ways (and only closed ways i.e. polygons). (BTW it is shown in JOSM hints in that window, with other useful examples for searching)

So if you type closed leisure=track you would get exactly what it sounds like (only closed ways tagged with leisure=track)

(You can also use those ctrl+f expressions in filter window, if you prefer that).

most simply, enter just building in that ctrl-f window. that will select all nodes, ways and relations that are tagged with building=*. Or, if you want just closed ways tagged as buildings (but no nodes nor relations), use filter string closed building or closed building=*

I’m note sure I follow. Usually, power plants and power substations are either closed ways or nodes (points) with appropriate power=* tags on them. If you “don’t want ways nor points” you won’t get much, if anything (well, you’ll get few relations, but without any coordinates).

Entering power=substation or power=plant in that ctrl+f window will select all nodes, ways and relations that are either power substations or power plants. If you enter (power=substation or power=plant) and type:relation, that would select only those which are relations, if that is what you want.


Short tutorial: basically in OSM you have:

  • nodes (dimensionless points with just coordinates)
  • ways (collections which are made from two or more points, connected in specified direction). Those ways may be:
    • open ways (i.e. just lines, e.g. highways)
    • closed ways (i.e. polygons, like for example buildings)
  • relations (collections of ways and/or nodes and/or other relations, which are somehow related in more complex ways. I’m guessing those are probably rarely used in your specific case)

All three (nodes, way, relations) can have 0 or more tags, which are key=value expressions (like e.g. building=kiosk or power=substation), and which specify what that node/way/relation actually represents.

Those tags cannot exist on their own - they are always attached to some node, way, or relation.

3 Likes

Fantastic! Thank you. I missed it somehow.