Add download, try key replacement

This commit is contained in:
Will Bradley 2025-06-29 11:54:56 -07:00
parent 32566cec12
commit 7332ef9748
2 changed files with 47 additions and 2 deletions

21
download.py Normal file
View 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)

View File

@ -296,7 +296,31 @@ class RoadComparator:
if uncovered_ratio > 0.5:
#uncovered_length >= min_length_deg and
# 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({
'geometry': geom,