Skip to content

Commit 7545c9d

Browse files
authored
Merge pull request #104 from cal-itp/explore-osm
Explore osm
2 parents 3e3d6ab + a5d2118 commit 7545c9d

File tree

6 files changed

+1536
-702
lines changed

6 files changed

+1536
-702
lines changed

_shared_utils/shared_utils/geography_utils.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,16 @@ def make_routes_shapefile(ITP_ID_LIST=[], CRS="EPSG:4326", alternate_df=None):
137137
pass
138138
else:
139139
# shape_id is None, which will throw up an error later on when there's groupby
140-
# So, create shape_id and fill it in with route_id info
141-
shapes = shapes.assign(
142-
shape_id=shapes.route_id,
143-
)
140+
# So, create shape_id and fill it in with route_id info, but only if it's missing
141+
# To flag these, shape_id as a column wouldn't even exist.
142+
if "shape_id" not in shapes.columns:
143+
shapes = shapes.assign(
144+
shape_id=shapes.route_id,
145+
)
146+
else:
147+
# This handles operators where most of their shape_ids are valid
148+
# Let's just drop missing ones.
149+
shapes = shapes[shapes.shape_id.notna()].reset_index(drop=True)
144150

145151
# Make a gdf
146152
shapes = gpd.GeoDataFrame(

0 commit comments

Comments
 (0)