Skip to content

Commit

Permalink
improve docstring and var names descriptiveness
Browse files Browse the repository at this point in the history
  • Loading branch information
gboeing committed Dec 28, 2023
1 parent 25a0d5d commit 15b9a27
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions osmnx/utils_geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def _quadrat_cut_geometry(geometry, quadrat_width):

def _intersect_index_quadrats(geometries, polygon):
"""
Identify geometries that intersect a (multi)polygon.
Identify geometries that intersect a (Multi)Polygon.
Uses an r-tree spatial index and cuts polygon up into smaller sub-polygons
for r-tree acceleration. Ensure that geometries and polygon are in the
Expand All @@ -356,11 +356,11 @@ def _intersect_index_quadrats(geometries, polygon):
Returns
-------
geoms_in_poly : set
index labels of geometries that intersected polygon
set of the index labels of the geometries that intersected the polygon
"""
# create an r-tree spatial index for the geometries
sindex = geometries.sindex
utils.log(f"Created r-tree spatial index for {len(geometries):,} geometries")
rtree = geometries.sindex
utils.log(f"Built r-tree spatial index for {len(geometries):,} geometries")

# cut polygon into chunks for faster spatial index intersecting. specify a
# sensible quadrat_width to balance performance (eg, 0.1 degrees is approx
Expand All @@ -376,7 +376,7 @@ def _intersect_index_quadrats(geometries, polygon):
for poly in multipoly.geoms:
poly_buff = poly.buffer(0)
if poly_buff.is_valid and poly_buff.area > 0:
possible_matches_iloc = sindex.intersection(poly_buff.bounds)
possible_matches_iloc = rtree.intersection(poly_buff.bounds)
possible_matches = geometries.iloc[list(possible_matches_iloc)]
precise_matches = possible_matches[possible_matches.intersects(poly_buff)]
geoms_in_poly.update(precise_matches.index)
Expand Down

0 comments on commit 15b9a27

Please sign in to comment.