From a large .osm/.o5m file (for India), I only want to extract the data that would actually show up when one is looking from zoom levels 1/0 through 8 (which is quite zoomed out.. only major cities, highways, geographical regions and coastlines). See screenshot, of a much smaller area loaded in Maperitive, seen at zoom level 8:

sample zoom level 8 view

The extracted .osm would then be much smaller in size, and I would be able to load it on Maperitive/other for just basic-zoom-levels rendering. I'm working with India's .osm downloaded from geofabrik.de. The .osm (with author and version info dropped) currently weighs over 3GBs.. impossible to load on my end, and we don't have access to any super-ish computers. Basically I want to get rid of all data that wouldn't show up at zoom level 8 or higher anyway. I'm working with osmconvert / osmfilter / maperitive, on Windows. Would prefer working with these simple portable apps and not get into postGIS databases etc, in the interest of making this doable for more people.

My understanding is that the data in the OSM file isn't tagged by zoom level; that there are algorithms and map styles that decide what gets displayed and what doesn't. So, it would be great if I could get a list of objects to --keep using osmfilter or similar. I don't want to do any major customization to the regular OSM rendering, and don't need to religiously stick to it either. Example, from the wiki page:

osmfilter norway.osm --keep="highway=primary =secondary waterway=river" >streets.osm

What source should I be looking up to get this --keep list?

  • The problem with "the data that would actually show up" is that it depends on the rendering style used. There is no "automatic" or "default" inclusion of certain features at certain zoom levels - hence the answers which including "finding out what features are included at a certain zoom level by looking at the map style". Nov 19, 2017 at 11:47

2 Answers 2


I suggest to go through the Mapnik style definition file. These can be:

Look out for the items that are used for low levels, and keep those.

For the zoom levels 0 to 5, Mapnik uses coastline shapefiles and Natural Earth data as well. What you will not get is the Postgis roads table with simplified geometry of roads to speed up rendering of low level tiles.

You might safely drop all amenities, buildings, trees and bus stops.

  • Thanks.. but I'm afraid I'm going to need to see some exact keys/commands. Also, it feels strange that I can't just automate this by supplying the style/rules file and maxZoom.
    – Nikhil VJ
    Jan 12, 2015 at 18:58

In addition to what AndreJ said, it might help to use osmconvert to determine which objects are large enough to be displayed at a requested zoom level. The --add-bboxweight-tags will help you:

--add-bboxweight-tags This option will add the binary logarithm of the bbox area of each way and each relation. For example: <tag k="bBoxWeight" v="20"/>

There are two other -add-bbox-* tags if the bboxweight tag should no suffice:

--add-bbox-tags This option adds a tag with a bounding box to each object. The tag will contain the border coordinates in this order: min Longitude, min Latitude, max Longitude , max Latitude. e.g.: <tag k="bBox" v="-0.5000,51.0000,0.5000,52.0000"/> --add-bboxarea-tags A tag for an estimated area value for the bbox is added to each way and each relation. The unit is square meters. For example: <tag k="bBoxArea" v="33828002"/>

Further information about osmconvert: https://wiki.openstreetmap.org/wiki/Osmconvert

To get help, enter osmconvert --help

One small hint concerning osmfilter: Filtering will work faster if you convert the .osm file to .o5m prior to using osmfilter.

osmconvert norway.osm -o=norway.o5m

  • Thanks.. this is a great lead that I hope to explore further. We're not at a conclusive answer yet, so not tick-marking this yet. Of course I'm working with .o5m input and only outputs are the inflated .osm .
    – Nikhil VJ
    Jan 15, 2015 at 15:36
  • The --add-bboxarea-tags is a significant lead. Most of the larger objects are composed of references to several smaller objects. Will the bBoxArea factor them all in? If yes, then can you show how to make the condition that only those parts get through that have bBoxArea greater than some value?
    – Nikhil VJ
    Jan 15, 2015 at 15:41
  • 1
    Yes, this will work with --add-bboxarea-tags, however, I would recommend using --add-bboxweight-tags instead. It's more efficient when writing the data at filtering. It will also produce smaller files. Example: osmconvert yourfile.pbf -o=input.o5m --- osmconvert input.o5m --add-bboxweight-tags -o=weight.o5m --- osmfilter weight.o5m --keep="bBoxWeight>=30" -o=out.o5m What it does: First, PBF file is converted to .o5m format. Then logarithmic weight tags are added. Finally, only large objects will remain in the file.
    – Marqqs
    Jan 17, 2015 at 21:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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