osmcode / osmium-tool

Command line tool for working with OpenStreetMap data based on the Osmium library.
https://osmcode.org/osmium-tool/
GNU General Public License v3.0
483 stars 104 forks source link

How to tag-filter only major cities? #228

Closed kuwapa closed 2 years ago

kuwapa commented 2 years ago

Hi, thanks a lot for this tool.

I'm trying to create a MBTiles file for the planet for zoom 1-5 only using tilemaker. In order to optimise the process, I'm first filtering out only the objects from osm which I need to create the zoom 1-5 map tiles. I am using the following command to generate the filtered .osm.pbf file -

osmium tags-filter portugal-latest.osm.pbf w/highway=motorway r/type=boundary n/place=city,state,country wr/natural=water -o portu.osm.pbf

I am stuck on two things -

  1. Generating boundaries for the state lines. The country boundary is being filtered, but not the state boundary lines.
  2. Filtering only major cities of a country. I'm not yet sure how to do that. I thought I could do so using the population value but then if I use a constant value, for some smaller countries, no cities might qualify. So is there any way to filter the capital city and a few more major cities in any country?
joto commented 2 years ago
  1. r/type=boundary should filter all kinds of boundaries. You have to look at the objects that are not matching your query and figure out why they don't. Sometimes boundaries are tagged as type=multipolygon, so maybe r/boundary=administrative is a better filter.
  2. You can filter only things with osmium tags-filter that can be expressed in simple filter expressions that tags-filter supports. What you want here might be beyond what it can do.

I recommend asking these kinds of beginner questions on help.osm.org, they are not really suitable for the osmium issue tracker.

kuwapa commented 2 years ago

Thanks. I'll try r/boundary=administrative.

Cool. Will post any questions on the osm forum in the future.