Skip to content

Commit 3e3d6ab

Browse files
author
tiffanychu90
committed
(geog_utils): remove try/except because shape_id NoneType handled above
1 parent 94222ab commit 3e3d6ab

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

_shared_utils/shared_utils/geography_utils.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,14 @@ def make_routes_shapefile(ITP_ID_LIST=[], CRS="EPSG:4326", alternate_df=None):
161161
shapes = shapes[shapes.num_stops > 1].reset_index(drop=True)
162162

163163
# Now, combine all the stops by stop sequence, and create linestring
164-
unique_shapes = list(shapes.shape_id.unique())
165-
166-
# Sometimes shape_id as NoneType comes up, and creates a problem, skip those
167-
try:
168-
for route in unique_shapes:
169-
single_shape = (
170-
shapes
171-
>> filter(_.shape_id == route)
172-
>> mutate(shape_pt_sequence=_.shape_pt_sequence.astype(int))
173-
# arrange in the order of stop sequence
174-
>> arrange(_.shape_pt_sequence)
175-
)
164+
for route in shapes.shape_id.unique():
165+
single_shape = (
166+
shapes
167+
>> filter(_.shape_id == route)
168+
>> mutate(shape_pt_sequence=_.shape_pt_sequence.astype(int))
169+
# arrange in the order of stop sequence
170+
>> arrange(_.shape_pt_sequence)
171+
)
176172

177173
# Convert from a bunch of points to a line (for a route, there are multiple points)
178174
route_line = shapely.geometry.LineString(list(single_shape["geometry"]))
@@ -188,8 +184,6 @@ def make_routes_shapefile(ITP_ID_LIST=[], CRS="EPSG:4326", alternate_df=None):
188184
all_routes = pd.concat(
189185
[all_routes, single_route], ignore_index=True, axis=0
190186
)
191-
except TypeError:
192-
print(f"unable to grab ID: {itp_id}, route: {route}")
193187

194188
all_routes = (
195189
all_routes.to_crs(CRS)

0 commit comments

Comments
 (0)