Skip to content

Commit

Permalink
add script to add iso3166-2 codes to geofabrik index file
Browse files Browse the repository at this point in the history
  • Loading branch information
pnoll1 committed Sep 7, 2024
1 parent 2d46a79 commit 82608fb
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions osmand_osm/osm/geofabrik_fix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import json

# dict area name to iso
iso_translation = {'baden-wuerttemberg':'de-bw', 'bayern':'de-by', 'berlin':'de-be', 'brandenburg':'de-bb', \
'hamburg':'de-hh', 'hessen':'de-he', 'mecklenburg-vorpommern':'de-mv', 'niedersachsen':'de-ni', \
'nordrhein-westfalen':'de-nw', 'rheinland-pfalz':'de-rp', 'saarland':'de-sl', 'sachsen':'de-sn', \
'sachsen-anhalt':'de-st', 'schleswig-holstein':'de-sh', 'thueringen':'de-th'}
# find area
with open('geofabrik_index-v1.json', 'r+') as index_file:
geofabrik_index = json.load(index_file)
area_list = geofabrik_index['features']
for area in area_list:
area_name = area['properties']['id']
for full_name in iso_translation:
if area_name == full_name:
area['properties']['iso3166-2'] = [iso_translation[area_name].upper()]
index_file.seek(0)
index_file.write(json.dumps(geofabrik_index))
index_file.truncate()

0 comments on commit 82608fb

Please sign in to comment.