osmnx icon indicating copy to clipboard operation
osmnx copied to clipboard

add `buffer_geometry` helper function to `utils_geo` module

Open gboeing opened this issue 1 year ago • 1 comments

This new function offers users a small quality-of-life improvement for use cases like:

  • modeling a buffered graph around some study area (e.g., #1072, https://github.com/gboeing/osmnx/pull/1044#issuecomment-2020261305)
  • retaining all edges that intersect a study area even if their endpoint nodes are all outside the study area (e.g., #1207)

For example, to download a graph within a 500 meter buffer of a city's boundaries:

import osmnx as ox
geom = ox.geocoder.geocode_to_gdf("Piedmont, CA, USA").iloc[0]["geometry"]
G = ox.graph.graph_from_polygon(ox.utils_geo.buffer_geometry(geom, 500), network_type="drive")

gboeing avatar Aug 22 '24 21:08 gboeing

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 98.31%. Comparing base (94b7e73) to head (95846f2). Report is 84 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1214   +/-   ##
=======================================
  Coverage   98.31%   98.31%           
=======================================
  Files          24       24           
  Lines        2369     2374    +5     
=======================================
+ Hits         2329     2334    +5     
  Misses         40       40           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Aug 22 '24 21:08 codecov[bot]