Sorry, mein Deutsch ist nicht so gut. Du kannst auf das kleine Globus-Symbol unter meinem Post klicken, um es zu übersetzen.
You could use GeoDesk for this task.
You just need a little bit of setup:
-
Install Python and a Java JVM (if your system doesn’t have them already)
-
Install the GeoDesk Python module: pip install geodesk
-
Download and install the GOL Tool
-
Turn your .osm.pbf file into a GOL: gol build germany germany-latest.osm.pbf
-
Copy the following script into sports_halls.py
:
from geodesk import *
germany = Features("germany.gol")
sports_halls = germany("na[building=sports_hall,sports_centre], na[building][leisure=sports_centre,sports_hall]")
cities = germany("a[boundary=administrative][admin_level=8]")
counties = germany("a[boundary=administrative][admin_level=6]")
states = germany("a[boundary=administrative][admin_level=4]")
def find_city(location):
city = cities.containing(location).first
if not city:
city = counties.containing(location).first
if not city:
city = states.containing(location).first
return city
print("name,lon,lat,city")
for hall in sports_halls:
location = hall.centroid
city_name = hall["addr:city"]
if city_name is None:
city = find_city(location)
if city:
city_name = city.name
if city_name is None:
city_name = "Unknown"
print(f'"{hall.name}",{location.lon},{location.lat},"{city_name}"')
This script retrieves all sports halls (similar to your Overpass query above). If it does not have an explicit addr:city
tag, the script checks the city in which the hall is located (administrative boundary of level 8, 6 or 4), and uses its name
instead.
- Run the script:
python sports_halls.py
This should give you a list like this:
name,lon,lat,city
"Mehrzweckhalle",8.3633573,54.9852222,"Kampen (Sylt)"
"Schwimmhalle List",8.4247487,55.0182719,"List auf Sylt"
"Sporthalle",7.8833456,54.1835547,"Helgoland"
(You can redirect the output into a file by adding >
and the file name, e.g. python sports_halls.py > turnhallen.csv
)
Let me know if you need to extract any other data, and I can show you how to update the script.