Comments (7)
I'll have some time to take a considered look at this soon.
from osmnx.
@EwoutH thanks and sorry for the delay. I'm still reflecting on this proposal. One thing I'm thinking about is if this could be generalized to a attach_features_to_nodes
function that would take arbitrary OSM features and add them to the nearest nodes. If it could be generalized in such a way, this could be a broadly useful enhancement.
from osmnx.
Thanks! That's an excellent idea, it might also be useful to see what stores, parks, public transport stops, bodies of water or anything else is close to certain nodes.
On thing that might be difficult is how to generalize. For example, in the case of parking spots I might want to know how many there are, so I want to take the sum
of capacity
. But simultaneously I want to keep bike
and car
parking separate. Maybe we can make some aggregation function for if there are multiple, for example.
from osmnx.
Simplest way is just to start with adding the feature data and doing aggregation manually.
So if I want to add parking spaces to a node:
# Proposed function enhancement
G = ox.add_parking_to_nodes(G, max_radius=500, parking_types=['car', 'motorcycle', 'bicycle'], only_public=True, include_distances=False)
You might get something like this:
# Example representation of parking spaces at a node
print(G.edges[0][1].feature_data)
[
{
'feature_type': 'Parking Lot',
'capacity': 20,
'fee': True,
'accessible': True, # Whether the parking lot is accessible to all
'security_level': 'High', # Security level of the parking lot
'electric_charging': False # Whether electric vehicle charging is available
},
{
'feature_type': 'Bicycle Rack',
'capacity': 10,
'covered': False, # Whether the bicycle rack is covered
'secured': True # Whether the bicycle rack is secured
},
{
'feature_type': 'Motorcycle Parking',
'capacity': 5,
'fee': False,
'covered': True, # Whether the motorcycle parking is covered
'security_level': 'Medium' # Security level of the motorcycle parking
}
]
And then users can aggerate the data however they like, and maybe in the future we could support some simple functions for it.
from osmnx.
Ok, I've had some time to reflect on this. In general, the OSMnx project follows 3 principles when adding new functionality: 1) it is useful to a broad set of users, 2) it generalizes well, and 3) it is not trivially easy for users to implement themselves. Your proposal satisfies point 1 but I don't think it satisfies points 2 and 3. Let me explain my thinking...
Let's say you create a street network graph and a GeoDataFrame of features, like this:
import osmnx as ox
import pandas as pd
place = "Piedmont, CA, USA"
G = ox.graph.graph_from_place(place, network_type="drive")
features = ox.features.features_from_place(place, {"amenity": "parking"})
It is trivially easy to attach your features to your graph's nearest nodes as attributes:
nn = ox.distance.nearest_nodes(G, features.centroid.x, features.centroid.y)
useful_tags = ["access", "parking", "surface", "capacity", "fee"]
for node, feature in zip(nn, features[useful_tags].to_dict(orient="records")):
feature = {k: v for k, v in feature.items() if pd.notna(v)}
G.nodes[node].update({"parking": feature})
I didn't initially consider how simple it would be to implement a basic version of this when I first read your proposal. Furthermore, I can imagine nearly infinite variation in how users would proceed from here with aggregation or customized attachment for their specific analytical goals. Because it's trivially easy to implement in just a few lines of code and it needs extreme flexibility to proceed from there for various analyses, this seems like the ideal use case to demonstrate in the examples gallery rather than building into the codebase itself.
Long story short: I think it's a great use case for OSMnx but is best served in the examples gallery rather than as a new feature in the codebase. A basic implementation is trivially simple, and a sufficiently flexible implementation to capture all use cases would be overly complex.
from osmnx.
from osmnx.
Thanks for getting back! I also didn't realise it would be this simple, in that case I agree an example is more than sufficient.
from osmnx.
Related Issues (20)
- Node Identification within Buffer Zone (if buffer was to be implemented) HOT 1
- PermissionError [ErrNo 13] when connecting to localhost using the latest docker image HOT 2
- Contributing guidelines link nowhere HOT 2
- Document usage limitations HOT 10
- UnicodeDecodeError in graph_from_xml on Windows Installations HOT 4
- Calling graph_from_place("Alaska", network_type="drive") throws GEOSException: TopologyException HOT 4
- Vasu HOT 1
- Unable to plot superimposed image HOT 1
- street networks graphs not working HOT 3
- AttributeError: module 'osmnx' has no attribute 'clean_intersections' HOT 2
- Removal of inner_polygons from outer_polygons (creation of holes), creates maximum one hole. HOT 5
- Fill missing values with most common value on similar roads HOT 4
- OSMnx 2.0 Migration Guide HOT 3
- Add junction/intersection types to nodes HOT 6
- Support directed bearing/orientation distributions and plots HOT 5
- Support loading and/or merging multiple networks HOT 5
- [Meta] Enable Discussions tab on this GitHub repo HOT 1
- Further API streamlining for v2 HOT 2
- _bearings_distribution: apply weight during histogram HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from osmnx.