Add download, try key replacement
This commit is contained in:
parent
32566cec12
commit
7332ef9748
21
download.py
Normal file
21
download.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import overpass
|
||||||
|
import json
|
||||||
|
|
||||||
|
api = overpass.API()
|
||||||
|
|
||||||
|
res = api.get("""
|
||||||
|
area[name="Florida"];
|
||||||
|
rel[name="Sumter County"](area);
|
||||||
|
map_to_area;
|
||||||
|
(
|
||||||
|
nwr[highway~"^(motorway|trunk|primary|secondary|tertiary|residential|unclassified|motorway_link|trunk_link|primary_link|secondary_link|tertiary_link)$"](area);
|
||||||
|
);
|
||||||
|
(._;>;);
|
||||||
|
""", responseformat="geojson")
|
||||||
|
|
||||||
|
# if you want a str, then use dumps function
|
||||||
|
#geojson_str = geojson.dumps(res)
|
||||||
|
|
||||||
|
# dump as file, if you want to save it in file
|
||||||
|
with open("./test.geojson",mode="w") as f:
|
||||||
|
json.dump(res, f)
|
28
threaded.py
28
threaded.py
@ -296,8 +296,32 @@ class RoadComparator:
|
|||||||
if uncovered_ratio > 0.5:
|
if uncovered_ratio > 0.5:
|
||||||
#uncovered_length >= min_length_deg and
|
#uncovered_length >= min_length_deg and
|
||||||
# Include entire original road with all original metadata
|
# Include entire original road with all original metadata
|
||||||
properties = dict(row.drop('geometry'))
|
original_properties = dict(row.drop('geometry'))
|
||||||
|
|
||||||
|
#
|
||||||
|
# For Sumter County Roads
|
||||||
|
#
|
||||||
|
properties = {
|
||||||
|
'surface': 'asphalt'
|
||||||
|
}
|
||||||
|
|
||||||
|
for key, value in original_properties.items():
|
||||||
|
if key == 'NAME':
|
||||||
|
properties['name'] = str(value).title() if value is not None else None
|
||||||
|
elif key == 'SpeedLimit':
|
||||||
|
properties['maxspeed'] = f"{value} mph" if value is not None else None
|
||||||
|
elif key == 'RoadClass':
|
||||||
|
if value.startswith('PRIMARY'):
|
||||||
|
properties['highway'] = 'trunk'
|
||||||
|
elif value.startswith('MAJOR'):
|
||||||
|
properties['highway'] = 'primary'
|
||||||
|
#elif value.startswith('MINOR'):
|
||||||
|
else:
|
||||||
|
properties['highway'] = 'residential'
|
||||||
|
# else:
|
||||||
|
# # Keep other properties as-is, or transform them as needed
|
||||||
|
# properties[key] = value
|
||||||
|
|
||||||
added_roads.append({
|
added_roads.append({
|
||||||
'geometry': geom,
|
'geometry': geom,
|
||||||
**properties
|
**properties
|
||||||
|
Loading…
x
Reference in New Issue
Block a user