Comments (6)
thanks @kuanb I've added a demo of this to the notebook!
from osmnx-examples.
@kuanb nice. How did you parameterize edge_buff
and node_buff
for the example image?
from osmnx-examples.
Those are both buffered at 25 (meters).
In the final example at the bottom of http://kuanbutts.com/2017/12/16/osmnx-isochrones/
I use 25 on edges and 50 on nodes (the above defaults).
from osmnx-examples.
I like how the blocks are filled-in in your example image above. But, I'm not seeing the same results when I parameterize your sample code that way:
def make_iso_polys(G, edge_buff=25, node_buff=50):
isochrone_polys = []
for trip_time in sorted(trip_times, reverse=True):
subgraph = nx.ego_graph(G, center_node, radius=trip_time, distance='time')
node_points = [Point((data['x'], data['y'])) for node, data in subgraph.nodes(data=True)]
nodes_gdf = gpd.GeoDataFrame({'id': subgraph.nodes()}, geometry=node_points)
nodes_gdf = nodes_gdf.set_index('id')
edge_lines = []
for n_fr, n_to in subgraph.edges():
f = nodes_gdf.loc[n_fr].geometry
t = nodes_gdf.loc[n_to].geometry
edge_lines.append(LineString([f,t]))
n = nodes_gdf.buffer(node_buff).geometry
e = gpd.GeoSeries(edge_lines).buffer(edge_buff).geometry
all_gs = list(n) + list(e)
new_iso = gpd.GeoSeries(all_gs).unary_union
isochrone_polys.append(new_iso)
return isochrone_polys
isochrone_polys = make_iso_polys(G, edge_buff=25, node_buff=25)
fig, ax = ox.plot_graph(G, fig_height=8, show=False, close=False, edge_color='k', edge_alpha=0.2, node_color='none')
for polygon, fc in zip(isochrone_polys, iso_colors):
patch = PolygonPatch(polygon, fc=fc, ec='none', alpha=0.6, zorder=-1)
ax.add_patch(patch)
plt.show()
Does it make sense for 25-meter buffers to fill in the blocks, as seen in your image? They are much larger than 25x25 meters, so this output I'm seeing makes sense with those parameters.
from osmnx-examples.
So sorry and thanks for pointing this out. I updated the post and also am including the fixed script here. I forgot to add on step to the method. I acknowledge this won't always work if you have a "donut" situation. Would need to think about a better way to handle such situations...
def make_iso_polys(G, edge_buff=25, node_buff=50, infill=False):
isochrone_polys = []
for trip_time in sorted(trip_times, reverse=True):
subgraph = nx.ego_graph(G, center_node, radius=trip_time, distance='time')
node_points = [Point((data['x'], data['y'])) for node, data in subgraph.nodes(data=True)]
nodes_gdf = gpd.GeoDataFrame({'id': subgraph.nodes()}, geometry=node_points)
nodes_gdf = nodes_gdf.set_index('id')
edge_lines = []
for n_fr, n_to in subgraph.edges():
f = nodes_gdf.loc[n_fr].geometry
t = nodes_gdf.loc[n_to].geometry
edge_lines.append(LineString([f,t]))
n = nodes_gdf.buffer(node_buff).geometry
e = gpd.GeoSeries(edge_lines).buffer(edge_buff).geometry
all_gs = list(n) + list(e)
new_iso = gpd.GeoSeries(all_gs).unary_union
# If desired, try and "fill in" surrounded
# areas so that shapes will appear solid and blocks
# won't have white space inside of them
if infill:
new_iso = Polygon(new_iso.exterior)
isochrone_polys.append(new_iso)
return isochrone_polys
from osmnx-examples.
Here's the result of the following script:
isochrone_polys = make_iso_polys(G, 25, 0, True)
fig, ax = ox.plot_graph(G, fig_height=8, show=False, close=False, edge_color='k', edge_alpha=0.2, node_color='none')
for polygon, fc in zip(isochrone_polys, iso_colors):
patch = PolygonPatch(polygon, fc=fc, ec='none', alpha=0.6, zorder=-1)
ax.add_patch(patch)
plt.show()
from osmnx-examples.
Related Issues (20)
- osmnx simplify_graph does not remove all intermediate nodes that are not intersections HOT 1
- Existing alternate isochrones example doesn't respect geometry of curved links HOT 2
- TypeError: unhashable type: 'dict' on first example in 00-osmnx-features-demo.ipynb HOT 5
- Install troubleshooting HOT 1
- TypeError: “Set type is unordered” in isochrones example with Pandas 1.1 HOT 1
- Finding all the edges connected to a node
- multiprocessing doesn't work in Jupyter HOT 1
- osmnx street network polar plot 1 bin backward than histogramas HOT 2
- Download whole state data HOT 1
- Fix binder link from master to main in README.md HOT 1
- Extracting boundaries with specified administrative level is not working correctly HOT 2
- [Question] would it be possible to show a trajectory (moving object) with Osmnx (stream plotting) HOT 1
- Am unable to use osmnx to get data for california, texas and some us state HOT 1
- module 'osmnx' has no attribute 'pois_from_point' HOT 1
- error in notebook 08 HOT 1
- Add Clustering Example by Network Distance HOT 1
- fix: isocrones are not taking into account the time HOT 1
- AttributeError: module 'osmnx' has no attribute 'utils_graph' in 00-osmnx-features-demo.ipynb HOT 2
- examples update needed HOT 2
- Add example of attaching features to nearest nodes
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-examples.