Manually update Osmnx with the file linked in this post from chesterharvey. https://github.com/gboeing/osmnx/issues/116#issuecomment-439577495 Final testing of feature still incomplete!
import osmnx as ox # Specify the name that is used to seach for the data place_name = "Santa Clara, Santa Clara County, California, USA" tags = { 'amenity': True, 'leisure': True, 'landuse': ['retail', 'commercial'], 'highway': 'bus_stop', } all_pois = ox.pois_from_place(place = place_name, tags = tags)
all_pois.loc[(all_pois['highway'] == 'bus_stop')]
Usage examples of the new POI querying functionality:
import osmnx as ox
ox.config(use_cache = True, log_console = True)
tags = {
'amenity': True,
'landuse': ['retail', 'commercial'],
'highway': 'bus_stop'
}
gdf = ox.pois_from_place(place = 'Piedmont, California, USA', tags = tags)
You can do that easily with footprints I think:
#point of interests around an aread import networkx as nx import osmnx as ox import requests #returns polygon or coordinates of poi #point = (59.912390, 10.750584) #amn = ["bus_station", 'waste_transfer_station'] #["bus_station", 'waste_transfer_station'] #points of interest / amenities we can use: https: //wiki.openstreetmap.org/wiki/Key:amenity def get_interest_points(long, lat, dist, amn[]): point = (long, lat) gdf_points = ox.pois_from_point(point, distance = dist, amenities = amn) return gdf_points[["amenity", "geometry"]] #Get bus buildings, distance in meter 400 is minimum #returns polygon of building def get_buildings(long, lat, dist): point = (long, lat) gdf = ox.footprints.footprints_from_point(point = point, distance = dist, footprint_type = 'buildings') return gdf["geometry"] #Get bus, tram or subway #type = "bus" or "tram" or "subway" #, distance in meter 400 is minimum #returns polygon of stop def get_buildings(long, lat, dist, type): point = (long, lat) gdf = ox.footprints.footprints_from_point(point = point, distance = dist, footprint_type = type) return gdf["geometry"]
I am trying to also show info of anycodings_osmnx OpenStreetMap bus-stop node 439460636 anycodings_osmnx (https://www.openstreetmap.org/node/439460636) anycodings_osmnx which is part of a highway.,How to make bootstrap modal form take input of emails from a table when the corresponding button of the table row is clicked,Azure DevOps: Is it not possible to use wildcard when searching for a string?,Uncaught TypeError: Cannot read properties of undefined (reading 'button')
I am using jupyter notebook for my analysis:
import osmnx as ox # Retrieve POI shelters place_name = 'Santa Clara, Santa Clara County, California, USA' shelter = ox.pois_from_place(place_name, amenities = ['shelter']) cols = ['amenity', 'name', 'element_type', 'shelter_type', 'building', 'network' ] shelter[cols]
cols = ['amenity', 'name', 'element_type', 'shelter_type',
'building', 'network'
]
shelter[cols].loc[(shelter['shelter_type'] == 'public_transport')]
cols = ['amenity', 'name','element_type', 'shelter_type',
'building', 'network'
]
shelter[cols].loc[(shelter['shelter_type'] == 'public_transport') ]
# Look bus - stop in highway graph = ox.graph_from_place(place_name) nodes, edges = ox.graph_to_gdfs(graph) nodes.loc[(nodes['highway'] == 'bus_stop')]
Manually update Osmnx with the file anycodings_osmnx linked in this post from chesterharvey. anycodings_osmnx https://github.com/gboeing/osmnx/issues/116#issuecomment-439577495 anycodings_osmnx Final testing of feature still anycodings_osmnx incomplete!
import osmnx as ox # Specify the name that is used to seach for the data place_name = "Santa Clara, Santa Clara County, California, USA" tags = { 'amenity': True, 'leisure': True, 'landuse': ['retail', 'commercial'], 'highway': 'bus_stop', } all_pois = ox.pois_from_place(place = place_name, tags = tags)
all_pois.loc[(all_pois['highway'] == 'bus_stop')]
Usage examples of the new POI querying anycodings_osmnx functionality:
import osmnx as ox
ox.config(use_cache = True, log_console = True)
tags = {
'amenity': True,
'landuse': ['retail', 'commercial'],
'highway': 'bus_stop'
}
gdf = ox.pois_from_place(place = 'Piedmont, California, USA', tags = tags)
You can do that easily with footprints I anycodings_osmnx think:
#point of interests around an aread import networkx as nx import osmnx as ox import requests #returns polygon or coordinates of poi #point = (59.912390, 10.750584) #amn = ["bus_station", 'waste_transfer_station'] #["bus_station", 'waste_transfer_station'] #points of interest / amenities we can use: https: //wiki.openstreetmap.org/wiki/Key:amenity def get_interest_points(long, lat, dist, amn[]): point = (long, lat) gdf_points = ox.pois_from_point(point, distance = dist, amenities = amn) return gdf_points[["amenity", "geometry"]] #Get bus buildings, distance in meter 400 is minimum #returns polygon of building def get_buildings(long, lat, dist): point = (long, lat) gdf = ox.footprints.footprints_from_point(point = point, distance = dist, footprint_type = 'buildings') return gdf["geometry"] #Get bus, tram or subway #type = "bus" or "tram" or "subway" #, distance in meter 400 is minimum #returns polygon of stop def get_buildings(long, lat, dist, type): point = (long, lat) gdf = ox.footprints.footprints_from_point(point = point, distance = dist, footprint_type = type) return gdf["geometry"]
Post date 2016-11-01
In a single line of code, OSMnx lets you download, model, and visualize the street network for, say, Modena Italy:
import osmnx as ox
ox.plot_graph(ox.graph_from_place('Modena, Italy'))
To acquire administrative boundary GIS data, one must typically track down shapefiles online and download them. But what about for bulk or automated acquisition and analysis? There must be an easier way than clicking through numerous web pages to download shapefiles one at a time. With OSMnx, you can download place shapes from OpenStreetMap (as geopandas GeoDataFrames) in one line of Python code – and project them to UTM (zone calculated automatically) and visualize in just one more line of code:
import osmnx as ox
city = ox.geocode_to_gdf('Berkeley, California')
ax = ox.project_gdf(city).plot()
_ = ax.axis('off')
You can just as easily get other place types, such as neighborhoods, boroughs, counties, states, or nations – any place geometry in OpenStreetMap:
place1 = ox.geocode_to_gdf('Manhattan, New York City, New York, USA')
place2 = ox.geocode_to_gdf('Cook County, Illinois')
place3 = ox.geocode_to_gdf('Iowa, USA')
place4 = ox.geocode_to_gdf('Bolivia')
This gets the drivable street network within some lat-long bounding box, in a single line of Python code, then projects it to UTM, then plots it:
G = ox.graph_from_bbox(37.79, 37.78, -122.41, -122.43, network_type = 'drive')
G_projected = ox.project_graph(G)
ox.plot_graph(G_projected)
This gets the street network within 0.75 km (along the network) of a latitude-longitude point:
G = ox.graph_from_point((37.79, -122.41), dist = 750, network_type = 'all')
ox.plot_graph(G)
bounding_box which is an optional parameter that can be used to filter OSM data geographically from specific area (see here for further details),network_filter attribute contains information about the rules that are applied when parsing different kind of roads from the OSM,When using Pyrosm, the first step is to initialize a specific reader object called OSM that is available from the pyrosm library:,Use bounding box to filter data from specific area
from pyrosm import get_data # Download data for the city of Helsinki fp = get_data("Helsinki") print(fp)
/tmp/pyrosm / Helsinki.osm.pbf
# Download the data into specified directory fp = get_data("helsinki", directory = "my_data") print("Data was downloaded to:", fp)
Data was downloaded to: /mnt/c / HY - DATA / hentenka / KOODIT / Uni / Pyrosm / docs / my_data / Helsinki.osm.pbf
# Refresh the data #-- -- -- -- -- -- -- -- # The first call won 't download the data because it was already downloaded earlier fp = get_data("Helsinki") print(fp) # This one will update the data and download the data print("\nDownload will happen:") fp = get_data("Helsinki", update = True) print(fp)
/tmp/pyrosm / Helsinki.osm.pbf
Download will happen:
Downloaded Protobuf data 'Helsinki.osm.pbf'(28.3 MB) to:
'/tmp/pyrosm/Helsinki.osm.pbf' /
tmp / pyrosm / Helsinki.osm.pbf