Shared bikes analysis
This is the beginning of series of a post, which describes work done together with @luisnateraNL @federicobattistonIT @correlaid @cityinteractionlab and @technologiestiftung and is inspired workshops and hackathons happening in Berlin and Paris.
For more detailed information about the files and work on bicycle data analysis please see the main folder for bike analysis in Berlin here:
Data about amenities extraction for Python: osmnx and pyrosm
Pyrosm and osmnx are both Python libraries that can be used to extract openstreetmap data (and do other things).
Pyrosm makes use of .pbf-files it gets from places like geofabrik. In its docs there is quite a few examples how to get different kinds of data.
Here are a few examples for Berlin and Hamburg prepared for the hackathon by Jasmin https://github.com/jasmincl/:
With example code :
import geopandas as gpd
from pyrosm import OSM, get_data
# Download data for Hamburg
fp = get_data("Hamburg")
# need to do this too to actually download it
print("\nDownload will happen:")
fp = get_data("Hamburg", update=True)
print(fp)
# initialize query to data
osm = OSM(fp)
# EXAMPLES
## get bus stops in Hamburg
busstop_filter = {"highway": ["bus_stop"]}
busstops = osm.get_pois(custom_filter=busstop_filter)
# get all amenities and shops (like in pyrosm docs)
custom_filter = {'amenity': True, "shop": True}
pois = osm.get_pois(custom_filter=custom_filter)
# check which amenity types there are
pois.amenity.unique()
# check which shop types there are
pois.shop.unique()
# one of the amenities available are restaurants! Filter geodataframe for restaurants
restaurants = pois[pois.amenity == "restaurant"]
# plot on a map
ax = restaurants.iloc[0:100,].plot(markersize=3, figsize=(12,12), legend=True, legend_kwds=dict(loc='upper left', ncol=5, bbox_to_anchor=(1, 1)))
Bicycle analysis data and further projects are updated on the repository with example notebooks: