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

osmfilter to extract all admin boundaries as areas and all places as dots

1
1

Before importing a huge world osm file with using osm2pgsql, I was recommended to use osmfilter to filter the input file down first. So that an osm file used for import only contains data that I need.

The final goal is to get all admin boundaries as areas, and all places as dots (like cities, villages, suburbs and so on). This data will be used in the following way:

  • admin boundaries are used to render a very simple map of a particular country (infographics)
  • places are used to put cities (as dots) on that map

That's basically all we need from the data.

We would like to automated populating data, so using osmtools sounds okay.

Тow, if the first stage is to filter down the big OSM file, what's the best configuration to only have data described above and nothing else? So that the final database is of small size and can be queried very fastly.

asked 03 Jul '17, 11:15

meglio's gravatar image

meglio
40337
accept rate: 0%


One Answer:

0

I don't know how to do that with osmfilter. But with Osmium it is simple:

osmium tags-filter planet.osm.pbf n/place=city r/type=boundary -o filtered.osm.pbf

answered 03 Jul '17, 18:03

Jochen%20Topf's gravatar image

Jochen Topf
5.2k55074
accept rate: 31%

edited 03 Jul '17, 18:03

Thanks @Jochen. In some cases, places can be represented as boundaries; in other cases, they can be represented as nodes. Is there any way to get only dots (nodes) and never boundaries for all my filtered places?

(03 Jul '17, 23:11) meglio

Source code available on GitHub .