Commit 24d4159 1 parent 037d04a commit 24d4159 Copy full SHA for 24d4159
File tree 2 files changed +153
-169
lines changed
2 files changed +153
-169
lines changed Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change 16
16
import typer
17
17
18
18
DEFAULT_MINI_DIST = 20.0 # meters
19
- HIGHWAY_VALUES = {
20
- None ,
21
- " " ,
22
- "bridleway" ,
23
- "footway" ,
24
- "motorway" ,
25
- "motorway_link" ,
26
- "pedestrian" ,
19
+ HIGHWAY_VALUES_TO_KEEP = {
27
20
"primary" ,
28
21
"primary_link" ,
29
22
"secondary" ,
30
23
"secondary_link" ,
31
- "service" ,
32
- "steps" ,
33
24
"tertiary" ,
34
25
"tertiary_link" ,
35
- "trunk" ,
36
- "trunk_link" ,
26
+ "residential" ,
37
27
}
38
28
39
29
app = typer .Typer ()
40
30
41
31
42
- def remove_highways (gdf : gpd .GeoDataFrame ):
43
- """Returns a copy of a GeoDataFrame of OpenStreetMap road features with highways
44
- removed .
32
+ def filter_by_highway_type (gdf : gpd .GeoDataFrame ):
33
+ """Returns a copy of a GeoDataFrame of OpenStreetMap road features filtered by
34
+ highway type .
45
35
46
36
Args:
47
37
gdf (geopandas.GeoDataFrame): OpenStreetMap features.
48
38
49
39
Returns:
50
- geopandas.GeoDataFrame: Copy of input GeoDataFrame with highway features
51
- removed .
40
+ geopandas.GeoDataFrame: Copy of input GeoDataFrame of features filtered by
41
+ highway type .
52
42
"""
53
43
if "highway" not in gdf .columns :
54
44
raise ValueError (
55
45
"'highway' column not found in input GeoDataFrame. "
56
46
"Input data must be of OpenStreetMap roads."
57
47
)
58
- out_gdf = gdf [~ gdf ["highway" ].isin (HIGHWAY_VALUES )].copy ()
48
+ out_gdf = gdf [gdf ["highway" ].isin (HIGHWAY_VALUES_TO_KEEP )].copy ()
59
49
return out_gdf
60
50
61
51
@@ -144,7 +134,7 @@ def main(
144
134
] = False ,
145
135
):
146
136
gdf = gpd .read_file (in_file )
147
- gdf = remove_highways (gdf )
137
+ gdf = filter_by_highway_type (gdf )
148
138
if drop_null :
149
139
gdf = gdf [~ gdf .geometry .isna ()]
150
140
else :
You can’t perform that action at this time.
0 commit comments