If you don’t mind a bit of Python scripting, you could use GeoDesk for this task. (We’re due to release an early-access version of GeoDesk for Python next week, but the binaries are already on PyPI).
-
Download the .osm.pbf files for the area you want to analyze (e.g. Geofabrik’s extracts for Germany)
-
Build a Geographic Object Library (GOL):
-
Install Python and pip install geodesk
-
Run the following script:
import geodesk
germany = geodesk.Features('/path/to/de.gol')
city_name = "Braunschweig"
city = germany(f"a[boundary=administrative][admin_level=6][name={city_name}]").one
parking_lots = germany("a[amenity=parking]")
city_parking_lots = parking_lots.within(city)
print(f"{city_parking_lots.area / city.area * 100 :.2f}% of the area"
f" of {city_name} is used for parking")
Here is what this script does:
-
It opens the GOL that you’ve created (in Step 2 above) and assigns it to germany
(This is the set of all features in the GOL)
-
It looks up the city that you want to analyze (or rather, the landkreis, since we’re using admin_level=6
)
-
It creates a set of all parking lots
-
It then restricts that set to only the parking lots within
the city’s area
-
Finally, it calculates the ratio of the total area of the city’s parking lots versus the entire city area, and reports it as a percentage.
Your result will look like this:
0.95% of the area of Braunschweig is used for parking
But if you really want to know just how much space is sacrificed to the Moloch dedicated to vehicles, you will want to take the road surfaces into account, as well. This part is trickier: In OSM, roads are mapped as ways, i.e. linestrings that by definition don’t have an area. A common approach is to take these lines and buffer them, which essentially turns them into polygons, whose area we can then calculate.
In the example below, I’m assuming that the average road is 6 meters wide, so we buffer the road shapes by 3 meters. (You can make this more accurate by querying each road type individually and applying different-sized buffers, then union the results.)
from geodesk import *
germany = Features('/path/to/de.gol')
city_name = "Braunschweig"
city = germany(f"a[boundary=administrative][admin_level=6][name={city_name}]").one
roads = germany("w[highway=residential,primary,secondary,tertiary,unclassified,service]")
road_shape = roads.within(city).shape.buffer(to_mercator(meters=3, lat=52))
print(f"{road_shape.area / city.shape.area * 100 :.2f}% of the area"
f" of {city_name} is used for roads")
Output:
3.96% of the area of Braunschweig is used for roads
(The buffer()
operation may take a minute or two)
I hope you will find this useful; let me know if you run into any issues. As I mentioned above, this is still pre-release, so you may encounter bugs (You can report them on GitHub).