Created
July 30, 2021 13:20
-
-
Save ThomasG77/003d087ad317bf871eabd0fb77a719eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import os | |
import requests | |
dir_path = os.path.dirname(os.path.realpath(__file__)) | |
r_roads = requests.get('https://omnesviae.org/roads.php') | |
r_all = requests.get('https://omnesviae.org/all.php') | |
features_roads = { | |
"type": "FeatureCollection", | |
"features": [] | |
} | |
for road in r_roads.json()['roads']: | |
features_roads["features"].append({ | |
"type": "Feature", | |
"properties": { | |
"kind": road["kind"] | |
}, | |
"geometry": { | |
"type": "LineString", | |
"coordinates": [list(reversed(coord)) for coord in road['points']] | |
} | |
}) | |
with open(os.path.join(dir_path, 'roads.geojson'), 'w') as outfile: | |
json.dump(features_roads, outfile) | |
features_markers = { | |
"type": "FeatureCollection", | |
"features": [] | |
} | |
for pt in r_all.json()['markers']: | |
features_markers["features"].append({ | |
"type": "Feature", | |
"properties": { | |
"id": pt[5], | |
"name": pt[0], | |
"desc": pt[1], | |
"source": "Tabula Peutingeriana" if pt[5][0] == "T" else "Itinerarium Antonini" | |
}, | |
"geometry": { | |
"type": "Point", | |
"coordinates": [pt[4], pt[3]] | |
} | |
}) | |
with open(os.path.join(dir_path, 'points.geojson'), 'w') as outfile: | |
json.dump(features_markers, outfile) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment