From 7332ef9748cfb0bdb4f30089cc27ed86f4c22b79 Mon Sep 17 00:00:00 2001 From: Will Bradley Date: Sun, 29 Jun 2025 11:54:56 -0700 Subject: [PATCH] Add download, try key replacement --- download.py | 21 +++++++++++++++++++++ threaded.py | 28 ++++++++++++++++++++++++++-- 2 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 download.py diff --git a/download.py b/download.py new file mode 100644 index 0000000..4700275 --- /dev/null +++ b/download.py @@ -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) \ No newline at end of file diff --git a/threaded.py b/threaded.py index 37ac125..bb05b24 100644 --- a/threaded.py +++ b/threaded.py @@ -296,8 +296,32 @@ 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, **properties