You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
692 B
29 lines
692 B
import json
|
|
import os
|
|
|
|
import mapbox_vector_tile
|
|
from tqdm import tqdm
|
|
|
|
tiles = os.listdir("tiles")
|
|
tiles = [t for t in tiles if t[:4] == "2024"]
|
|
|
|
|
|
def to_geojson(tile):
|
|
tile_path = f"tiles/{tile}"
|
|
with open(tile_path, "rb") as f:
|
|
pbf = f.read()
|
|
decoded = mapbox_vector_tile.decode(pbf)
|
|
features = decoded["travel"]["features"]
|
|
if len(features) == 0:
|
|
return
|
|
else:
|
|
features_properties = [f["properties"] for f in features]
|
|
|
|
filename = os.path.splitext(tile)[0]
|
|
with open(f"geojson2024/{filename}.geojson", "w") as f:
|
|
json.dump(features_properties, f, ensure_ascii=False)
|
|
|
|
|
|
[to_geojson(t) for t in tiles]
|
|
print("end")
|