diff --git a/notebooks/space2stats_api_adm_example.ipynb b/notebooks/space2stats_api_adm_example.ipynb index 5e8a083..7be7fd9 100644 --- a/notebooks/space2stats_api_adm_example.ipynb +++ b/notebooks/space2stats_api_adm_example.ipynb @@ -2,14 +2,16 @@ "cells": [ { "cell_type": "code", - "execution_count": 48, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ + "import json\n", + "from typing import Dict\n", + "\n", "import requests\n", "import geopandas as gpd\n", "import pandas as pd\n", - "import json\n", "from shapely.geometry import shape\n", "import numpy as np\n", "from lonboard import Map, ScatterplotLayer" @@ -17,18 +19,19 @@ }, { "cell_type": "code", - "execution_count": 49, + "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "BASE_URL = \"http://127.0.0.1:8000\"\n", "FIELDS_ENDPOINT = f\"{BASE_URL}/fields\"\n", - "SUMMARY_ENDPOINT = f\"{BASE_URL}/summary\"" + "SUMMARY_ENDPOINT = f\"{BASE_URL}/summary\"\n", + "AGGREGATION_ENDPOINT = f\"{BASE_URL}/aggregate\"" ] }, { "cell_type": "code", - "execution_count": 54, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -64,7 +67,7 @@ }, { "cell_type": "code", - "execution_count": 55, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -152,7 +155,7 @@ "
\n", + " | geometry | \n", + "shapeName | \n", + "shapeISO | \n", + "shapeID | \n", + "shapeGroup | \n", + "shapeType | \n", + "sum_pop_2020 | \n", + "
---|---|---|---|---|---|---|---|
0 | \n", + "POLYGON ((36.05061 4.45622, 35.94395 4.54803, ... | \n", + "Turkana | \n", + "KE-43 | \n", + "32016919B72266624462344 | \n", + "KEN | \n", + "ADM1 | \n", + "1.354744e+06 | \n", + "
1 | \n", + "POLYGON ((36.60089 2.40574, 36.60138 2.4053, 3... | \n", + "Marsabit | \n", + "KE-25 | \n", + "32016919B63496705134089 | \n", + "KEN | \n", + "ADM1 | \n", + "4.205930e+05 | \n", + "
2 | \n", + "POLYGON ((40.99195 2.17919, 40.99245 2.25188, ... | \n", + "Mandera | \n", + "KE-24 | \n", + "32016919B2031803566233 | \n", + "KEN | \n", + "ADM1 | \n", + "2.739353e+06 | \n", + "
3 | \n", + "POLYGON ((38.96255 2.09739, 38.96272 2.09718, ... | \n", + "Wajir | \n", + "KE-46 | \n", + "32016919B89873713911655 | \n", + "KEN | \n", + "ADM1 | \n", + "1.901271e+06 | \n", + "
4 | \n", + "POLYGON ((34.94278 2.45547, 34.93892 2.45551, ... | \n", + "West Pokot | \n", + "KE-47 | \n", + "32016919B96045830258165 | \n", + "KEN | \n", + "ADM1 | \n", + "9.151929e+05 | \n", + "
5 | \n", + "POLYGON ((36.39206 0.91877, 36.39192 0.91835, ... | \n", + "Samburu | \n", + "KE-37 | \n", + "32016919B77230315601578 | \n", + "KEN | \n", + "ADM1 | \n", + "3.655148e+05 | \n", + "
6 | \n", + "POLYGON ((37.94529 1.26288, 37.94816 1.19432, ... | \n", + "Isiolo | \n", + "KE-09 | \n", + "32016919B62684442090944 | \n", + "KEN | \n", + "ADM1 | \n", + "2.879396e+05 | \n", + "
7 | \n", + "POLYGON ((35.79194 1.66362, 35.79185 1.66355, ... | \n", + "Baringo | \n", + "KE-01 | \n", + "32016919B50719068904883 | \n", + "KEN | \n", + "ADM1 | \n", + "9.343517e+05 | \n", + "
8 | \n", + "POLYGON ((35.15214 1.19937, 35.16018 1.18046, ... | \n", + "Elgeyo-Marakwet | \n", + "KE-05 | \n", + "32016919B59887050611600 | \n", + "KEN | \n", + "ADM1 | \n", + "7.246405e+05 | \n", + "
9 | \n", + "POLYGON ((34.82229 1.26259, 34.82192 1.26249, ... | \n", + "Trans Nzoia | \n", + "KE-42 | \n", + "32016919B1149170155930 | \n", + "KEN | \n", + "ADM1 | \n", + "1.461817e+06 | \n", + "
10 | \n", + "POLYGON ((34.58077 1.15033, 34.58031 1.15027, ... | \n", + "Bungoma | \n", + "KE-03 | \n", + "32016919B68325359473156 | \n", + "KEN | \n", + "ADM1 | \n", + "2.119163e+06 | \n", + "
11 | \n", + "POLYGON ((39.46069 0.99468, 39.4606 0.99454, 3... | \n", + "Garissa | \n", + "KE-07 | \n", + "32016919B57902629823981 | \n", + "KEN | \n", + "ADM1 | \n", + "1.732643e+06 | \n", + "
12 | \n", + "POLYGON ((35.58744 0.1695, 35.58558 0.16949, 3... | \n", + "Uasin Gishu | \n", + "KE-44 | \n", + "32016919B81086936948851 | \n", + "KEN | \n", + "ADM1 | \n", + "1.726894e+06 | \n", + "
13 | \n", + "POLYGON ((35.01771 0.88754, 35.01777 0.88714, ... | \n", + "Kakamega | \n", + "KE-11 | \n", + "32016919B72187572718143 | \n", + "KEN | \n", + "ADM1 | \n", + "2.831936e+06 | \n", + "
14 | \n", + "POLYGON ((36.48872 0.8468, 36.47331 0.8385, 36... | \n", + "Laikipia | \n", + "KE-20 | \n", + "32016919B40191501607276 | \n", + "KEN | \n", + "ADM1 | \n", + "8.413015e+05 | \n", + "
15 | \n", + "POLYGON ((34.36053 0.77841, 34.36019 0.77841, ... | \n", + "Busia | \n", + "KE-04 | \n", + "32016919B17784979587790 | \n", + "KEN | \n", + "ADM1 | \n", + "1.395027e+06 | \n", + "
16 | \n", + "POLYGON ((37.38583 0.27442, 37.38543 0.2741, 3... | \n", + "Meru | \n", + "KE-26 | \n", + "32016919B42702125036935 | \n", + "KEN | \n", + "ADM1 | \n", + "1.891276e+06 | \n", + "
17 | \n", + "POLYGON ((34.8503 0.54573, 34.87022 0.53017, 3... | \n", + "Nandi | \n", + "KE-32 | \n", + "32016919B10848562282373 | \n", + "KEN | \n", + "ADM1 | \n", + "1.540833e+06 | \n", + "
18 | \n", + "POLYGON ((34.37066 0.30656, 34.37043 0.30635, ... | \n", + "Siaya | \n", + "KE-38 | \n", + "32016919B12007380424127 | \n", + "KEN | \n", + "ADM1 | \n", + "1.305017e+06 | \n", + "
19 | \n", + "POLYGON ((35.64015 -0.06097, 35.63872 -0.06193... | \n", + "Nakuru | \n", + "KE-31 | \n", + "32016919B58088177642376 | \n", + "KEN | \n", + "ADM1 | \n", + "2.627695e+06 | \n", + "
20 | \n", + "POLYGON ((34.56035 0.09393, 34.56017 0.09377, ... | \n", + "Vihiga | \n", + "KE-45 | \n", + "32016919B20488296424250 | \n", + "KEN | \n", + "ADM1 | \n", + "1.089803e+06 | \n", + "
21 | \n", + "POLYGON ((36.25549 -0.02196, 36.25241 -0.03496... | \n", + "Nyandarua | \n", + "KE-35 | \n", + "32016919B99956097556155 | \n", + "KEN | \n", + "ADM1 | \n", + "8.733263e+05 | \n", + "
22 | \n", + "POLYGON ((37.30779 -0.15107, 37.30811 -0.15135... | \n", + "Tharaka | \n", + "KE-41 | \n", + "32016919B40030396675644 | \n", + "KEN | \n", + "ADM1 | \n", + "5.742413e+05 | \n", + "
23 | \n", + "POLYGON ((35.5228 0.01541, 35.51604 0.01586, 3... | \n", + "Kericho | \n", + "KE-12 | \n", + "32016919B28150779100642 | \n", + "KEN | \n", + "ADM1 | \n", + "1.224764e+06 | \n", + "
24 | \n", + "POLYGON ((34.74707 -0.02473, 34.7458 -0.02473,... | \n", + "Kisumu | \n", + "KE-17 | \n", + "32016919B35081513576883 | \n", + "KEN | \n", + "ADM1 | \n", + "1.640107e+06 | \n", + "
25 | \n", + "POLYGON ((36.65747 -0.15308, 36.68586 -0.17446... | \n", + "Nyeri | \n", + "KE-36 | \n", + "32016919B26862024603939 | \n", + "KEN | \n", + "ADM1 | \n", + "9.768039e+05 | \n", + "
26 | \n", + "POLYGON ((38.43415 -0.07482, 38.82981 -0.76018... | \n", + "Tana River | \n", + "KE-40 | \n", + "32016919B56782604912852 | \n", + "KEN | \n", + "ADM1 | \n", + "4.313174e+05 | \n", + "
27 | \n", + "POLYGON ((38.4207 -0.06928, 38.42054 -0.06922,... | \n", + "Kitui | \n", + "KE-18 | \n", + "32016919B87039477224343 | \n", + "KEN | \n", + "ADM1 | \n", + "1.363067e+06 | \n", + "
28 | \n", + "POLYGON ((37.16912 -0.63562, 37.16915 -0.63586... | \n", + "Kirinyaga | \n", + "KE-15 | \n", + "32016919B58720683486854 | \n", + "KEN | \n", + "ADM1 | \n", + "8.014714e+05 | \n", + "
29 | \n", + "POLYGON ((37.30779 -0.15107, 37.41457 -0.39432... | \n", + "Embu | \n", + "KE-06 | \n", + "32016919B43560273720920 | \n", + "KEN | \n", + "ADM1 | \n", + "7.789369e+05 | \n", + "
30 | \n", + "POLYGON ((33.94766 -0.33718, 33.9281 -0.45482,... | \n", + "Homa Bay | \n", + "KE-08 | \n", + "32016919B3301153840115 | \n", + "KEN | \n", + "ADM1 | \n", + "1.592400e+06 | \n", + "
31 | \n", + "POLYGON ((35.45109 -0.3654, 35.45009 -0.36632,... | \n", + "Bomet | \n", + "KE-02 | \n", + "32016919B53683499362611 | \n", + "KEN | \n", + "ADM1 | \n", + "1.599673e+06 | \n", + "
32 | \n", + "POLYGON ((35.01961 -0.4124, 35.01892 -0.41273,... | \n", + "Nyamira | \n", + "KE-34 | \n", + "32016919B45734544235065 | \n", + "KEN | \n", + "ADM1 | \n", + "1.118468e+06 | \n", + "
33 | \n", + "POLYGON ((35.58665 -0.58811, 35.39608 -0.64488... | \n", + "Narok | \n", + "KE-33 | \n", + "32016919B83281423333591 | \n", + "KEN | \n", + "ADM1 | \n", + "1.852574e+06 | \n", + "
34 | \n", + "POLYGON ((34.63766 -0.66513, 34.63659 -0.67013... | \n", + "Kisii | \n", + "KE-16 | \n", + "32016919B92888924192138 | \n", + "KEN | \n", + "ADM1 | \n", + "1.792312e+06 | \n", + "
35 | \n", + "POLYGON ((36.72004 -0.80637, 36.72087 -0.80709... | \n", + "Murang'a | \n", + "KE-29 | \n", + "32016919B92229445677015 | \n", + "KEN | \n", + "ADM1 | \n", + "1.374206e+06 | \n", + "
36 | \n", + "POLYGON ((33.92824 -0.80242, 33.93507 -1.0011,... | \n", + "Migori | \n", + "KE-27 | \n", + "32016919B50702580177250 | \n", + "KEN | \n", + "ADM1 | \n", + "1.408945e+06 | \n", + "
37 | \n", + "POLYGON ((36.53373 -1.15591, 36.51061 -1.24019... | \n", + "Kiambu | \n", + "KE-13 | \n", + "32016919B11020559484650 | \n", + "KEN | \n", + "ADM1 | \n", + "3.549037e+06 | \n", + "
38 | \n", + "POLYGON ((37.84551 -0.80983, 37.84511 -0.80993... | \n", + "Machakos | \n", + "KE-22 | \n", + "32016919B39119671019936 | \n", + "KEN | \n", + "ADM1 | \n", + "2.066440e+06 | \n", + "
39 | \n", + "POLYGON ((36.33392 -1.04937, 36.34618 -1.17568... | \n", + "Kajiado | \n", + "KE-10 | \n", + "32016919B31527762068828 | \n", + "KEN | \n", + "ADM1 | \n", + "1.196777e+06 | \n", + "
40 | \n", + "POLYGON ((36.66389 -1.31521, 36.65987 -1.32207... | \n", + "Nairobi | \n", + "KE-30 | \n", + "32016919B57908315498598 | \n", + "KEN | \n", + "ADM1 | \n", + "5.595780e+06 | \n", + "
41 | \n", + "POLYGON ((37.75332 -1.56638, 37.75275 -1.56655... | \n", + "Makueni | \n", + "KE-23 | \n", + "32016919B42227953152284 | \n", + "KEN | \n", + "ADM1 | \n", + "1.188003e+06 | \n", + "
42 | \n", + "MULTIPOLYGON (((40.20794 -2.03289, 40.21904 -2... | \n", + "Lamu | \n", + "KE-21 | \n", + "32016919B38538724963648 | \n", + "KEN | \n", + "ADM1 | \n", + "1.487228e+05 | \n", + "
43 | \n", + "MULTIPOLYGON (((39.21737 -3.07293, 39.15588 -3... | \n", + "Kilifi | \n", + "KE-14 | \n", + "32016919B27781338411646 | \n", + "KEN | \n", + "ADM1 | \n", + "1.781396e+06 | \n", + "
44 | \n", + "POLYGON ((39.07511 -3.04114, 39.07503 -3.04111... | \n", + "Taita Taveta | \n", + "KE-39 | \n", + "32016919B21030921481039 | \n", + "KEN | \n", + "ADM1 | \n", + "4.408730e+05 | \n", + "
45 | \n", + "MULTIPOLYGON (((39.09229 -3.56708, 39.06294 -3... | \n", + "Kwale | \n", + "KE-19 | \n", + "32016919B50438423394723 | \n", + "KEN | \n", + "ADM1 | \n", + "1.007128e+06 | \n", + "
46 | \n", + "MULTIPOLYGON (((39.64795 -3.95101, 39.64832 -3... | \n", + "Mombasa | \n", + "KE-28 | \n", + "32016919B10079274489584 | \n", + "KEN | \n", + "ADM1 | \n", + "1.281050e+06 | \n", + "