Skip to content

Commit

Permalink
update endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
clkruse committed Dec 5, 2022
1 parent 17c4dd5 commit 77fb917
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions notebooks/explorations/compile_detected_sites.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,33 @@
"cells": [
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/ckruse/miniforge3/envs/m1-plastics/lib/python3.9/site-packages/geopandas/io/file.py:362: FutureWarning: pandas.Int64Index is deprecated and will be removed from pandas in a future version. Use pandas.Index with the appropriate dtype instead.\n",
" pd.Int64Index,\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"We have detected and confirmed 4,137 sites in 112 countries\n",
"There are 1095 sites within 250m of a waterway (26.5%)\n",
"There are 515 sites within 100m of a waterway (12.4%)\n",
"On average, 5,457 people live within 1 km of a site and 127,671 people live within 5 km\n"
]
}
],
"source": [
"import requests\n",
"import geopandas as gpd\n",
"\n",
"endpoint = 'http://api.plastic.watch.earthrise.media/sites?limit=10000'\n",
"endpoint = 'http://api.globalplasticwatch.org/sites?limit=10000'\n",
"auth = requests.auth.HTTPBasicAuth('admin', 'plastics')\n",
"params = {'apikey': 'jahsdbvjahsdvaulhsdvoauysdg82973bq', 'limit': '10000'}\n",
"response = requests.get(endpoint, auth=auth, params=params)\n",
Expand All @@ -30,6 +49,13 @@
"print(f\"There are {sum(data['Distance to Waterway (m)'] < 100)} sites within 100m of a waterway ({sum(data['Distance to Waterway (m)'] < 100) / len(data):.1%})\")\n",
"print(f\"On average, {data['Population - 1 km'].mean():,.0f} people live within 1 km of a site and {data['Population - 5 km'].mean():,.0f} people live within 5 km\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down

0 comments on commit 77fb917

Please sign in to comment.