Skip to content

Commit

Permalink
Merge pull request #1 from ClimateImpactLab/gadm-download
Browse files Browse the repository at this point in the history
Add GADM download
  • Loading branch information
bolliger32 authored Apr 11, 2022
2 parents 4a20040 + c0ece94 commit 6669fe5
Showing 1 changed file with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,14 @@
"import ssl\n",
"import subprocess\n",
"import tarfile\n",
"from io import BytesIO\n",
"from pathlib import Path\n",
"from urllib import request as urequest\n",
"from zipfile import ZipFile\n",
"import zipfile\n",
"\n",
"import dask.distributed as dd\n",
"import pandas as pd\n",
"import requests\n",
"from dask_gateway import Gateway\n",
"from pandas_datareader import wb as dr_wb\n",
"from tqdm.auto import tqdm\n",
"\n",
"from sliiders import settings as sset\n",
"\n",
Expand Down Expand Up @@ -78,6 +75,7 @@
" sset.DIR_IIASA_PROJECTIONS,\n",
" sset.DIR_GEOG_DATUMS_XGM2019e_WGS84,\n",
" sset.DIR_GEOG_DATUMS_EGM96_WGS84,\n",
" sset.DIR_GADM,\n",
"]\n",
"for direc in directories_to_create:\n",
" direc.mkdir(exist_ok=True, parents=True)"
Expand Down Expand Up @@ -568,6 +566,31 @@
"urequest.urlretrieve(URL_SRTM15, SRTM15PLUS_DIRECTORY / URL_SRTM15.split(\"/\")[-1])"
]
},
{
"cell_type": "markdown",
"id": "40116a24-ac34-4a9a-884d-90d2738dda07",
"metadata": {},
"source": [
"### GADM v3.6"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "93bb86d9-d337-44ad-9a37-d5531f9f6beb",
"metadata": {},
"outputs": [],
"source": [
"URL_GADM = \"https://biogeo.ucdavis.edu/data/gadm3.6/gadm36_levels_gpkg.zip\"\n",
"PATH_GADM_ZIP = sset.DIR_GADM / URL_GADM.split('/')[-1]\n",
"urequest.urlretrieve(URL_GADM, PATH_GADM_ZIP)\n",
"\n",
"sset.PATH_GADM.parent.mkdir(exist_ok=True)\n",
"\n",
"with zipfile.ZipFile(PATH_GADM_ZIP, mode='r') as z:\n",
" z.extractall(sset.PATH_GADM.parent)"
]
},
{
"cell_type": "markdown",
"id": "d5efcb44-1f60-4377-9d01-e970b918ca5e",
Expand Down

0 comments on commit 6669fe5

Please sign in to comment.