Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin1 boundaries etl #15

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions geo/admin_boundaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
import json
from shapely.geometry import shape, mapping
import pandas as pd

DATA_DIR = '/dbfs/mnt/DAP/data/admin1geoboundaries'
DATA_DIR = '/Volumes/prd_mega/sboost4/vboost4/Workspace/auxiliary_data/admin1geoboundaries'
WB_ADM1_GEO_FILENAME = f'{DATA_DIR}/WB_admin1geoboundaries.geojson'
ALT_ADM1_GEO_FILENAME = f'{DATA_DIR}/ALT_admin1geoboundaries.geojson'

Expand Down Expand Up @@ -63,7 +62,7 @@ def get_params(xmin, ymin, xmax, ymax):

print(f'Exported {len(features)} admin 1 geo boundary records to {WB_ADM1_GEO_FILENAME}')


# COMMAND ----------

# Obtaining suitable boundaries (not available within the WB boundaries) from other sources for select countries

Expand Down Expand Up @@ -96,6 +95,9 @@ def simplify_geometry(geometry, tolerance=0.01):
]
assert len(boundaries_KEN['features']) == 47, f"Expected 47 subnational regions, got {len(boundaries_KEN['features'])}"


# COMMAND ----------

# Bangladesh boundaries
BGD_URL = 'https://github.com/wmgeolab/geoBoundaries/raw/main/releaseData/gbOpen/BGD/ADM1/geoBoundaries-BGD-ADM1.geojson'
boundaries_BGD = requests.get(BGD_URL).json()
Expand Down Expand Up @@ -123,4 +125,3 @@ def simplify_geometry(geometry, tolerance=0.01):
boundaries_alt = {'type':'FeatureCollection', 'features':features_KEN+features_BGD}
with open(ALT_ADM1_GEO_FILENAME, 'w', encoding='utf-8') as f:
json.dump(boundaries_alt, f, ensure_ascii=False, indent=2)

2 changes: 1 addition & 1 deletion geo/admin_boundaries_dlt.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from pyspark.sql.types import StructType, StructField, DoubleType
from shapely.ops import unary_union

DATA_DIR = '/dbfs/mnt/DAP/data/admin1geoboundaries'
DATA_DIR = '/Volumes/prd_mega/sboost4/vboost4/Workspace/auxiliary_data/admin1geoboundaries'

# admin1 name corrections
correct_admin1_names = {
Expand Down