Skip to content

Commit

Permalink
Merge pull request #34 from OCHA-DAP/update-geojsons
Browse files Browse the repository at this point in the history
Update geojsons for DRC
  • Loading branch information
t-downing authored Dec 10, 2024
2 parents 0f566f5 + 07d8fa8 commit cd05bec
Show file tree
Hide file tree
Showing 5 changed files with 313 additions and 5 deletions.
4 changes: 3 additions & 1 deletion assets/geo/adm0.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion assets/geo/adm0_outline.json

Large diffs are not rendered by default.

38 changes: 37 additions & 1 deletion assets/geo/adm1.json

Large diffs are not rendered by default.

244 changes: 243 additions & 1 deletion assets/geo/adm2.json

Large diffs are not rendered by default.

28 changes: 27 additions & 1 deletion download_geodata.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pandas as pd

from constants import ADMS, ISO3S
from utils import codab_utils
from utils import codab_utils, data_utils


def clean_gdf(gdf):
Expand All @@ -20,7 +20,33 @@ def clean_gdf(gdf):
return gdf


def load_geo_data(save_to_database=True):
"""Load geo data from blob storage and save to database."""
adms = []
for iso3 in ISO3S:
print(f"loading {iso3} adm to migrate")
gdf_in = codab_utils.load_codab_from_blob(iso3, admin_level=2)
adms.append(gdf_in)
adm = pd.concat(adms, ignore_index=True)

for adm_level in range(3):
adm[f"ADM{adm_level}_NAME"] = adm[f"ADM{adm_level}_FR"].fillna(
adm[f"ADM{adm_level}_FR"]
)
adm.drop(columns=["geometry"], inplace=True)
adm.columns = adm.columns.str.lower()
if save_to_database:
adm.to_sql(
"adm",
schema="app",
con=data_utils.get_engine(stage="dev"),
if_exists="replace",
index=False,
)


if __name__ == "__main__":
load_geo_data()
for adm in ADMS:
print(f"Processing geo data for admin {adm}...")
gdfs = []
Expand Down

0 comments on commit cd05bec

Please sign in to comment.