How to become ohsome part 6: Introducing the magical filter parameter

it's magic!

We are back again with a fresh part of the How to become ohsome blog series. In case this 6th part of the series is your first one, or you have not heard from our awesome OpenStreetMap History Data Analytics Platform before (short form: ohsome platform), don’t worry. We’ve added some context, as well as links to other relevant blog posts at the end of this one.

Within the open source release 1.0 of the ohsome API, we’ve introduced a new parameter that is simply called filter. You might wonder now what is so magical about this parameter. Its syntax comes from the wizard used in Overpass Turbo, a well established and widely used tool within the OpenStreetMap community to query OSM data. But let’s get back to our new ohsome feature. This filter substitutes the former types, keys and values parameters and adds new functionalities on top of it. Here, we’ve prepared a couple of examples that should give you an idea of how it works and what you can do with it.

If you want to compute the amount of area that is covered with a forest, you usually need to consider two tags: landuse=forest as well as natural=wood. With any pre 1.0 version of the ohsome API, you would have to make two requests, one for each of these key-value combinations. Using this new magical parameter, you can combine both of them in one single request. The filter would then have the following syntax: (landuse=forest or natural=wood) and geometry:polygon. As you can see, the syntax is similar to SQL, where you can combine different tags with the and or the or keywords and use brackets to influence the precedence. The tags themself are given in the key=value syntax and an additional filter on the geometry uses geometry:geomType to be distinguishable from the tags. Click here for sending a test request using a bbox around the German city Dresden.

The second example that we want to show you is a little quality analysis and focuses on residential roads without a name tag. The filter syntax looks like that: type:way and highway=residential and name!=* and noname!=yes. With this filter, we get all way features that have the highway=residential tag, don’t have any name tag and also don’t have the noname=yes tag. Additionally, this example shows the usage of the OSM types filter, again using the colon instead of the equals sign to distinguish it from an OSM tag. We’ve prepared another example request using this filter.

You can find further examples and explanations directly on the filter subpage of our new documentation page. The code that performs the processing of the filter parameter has also been published as a standalone library, so this functionality can be easily included in other applications as well. Also checkout our recently published post about the new documentation page of the ohsome API. As always, make sure to hit the like button and subscribe to our.. oh wait.. wrong platform. Anyway, if you want to know more about our ohsome framework, don’t hesitate to reach out to us via info(at)heigit.org or contact any member of our team directly. Stay ohsome!

Context: the aim of the ohsome OpenStreetMap History Data Analytics Platform is to make OpenStreetMap’s full-history data more easily accessible for various kinds of OSM data analytics tasks, such as data quality analysis, on a global scale. The ohsome API is one of its components, providing free and easy access to some of the functionalities of the ohsome platform via HTTP requests. Some intro can be found here:

Comments are closed.