Browse Source

restrict to year=2011; fix failing aggregation

Fabian Peter Hammerle 4 years ago
parent
commit
f2fa3ecd56
1 changed files with 20 additions and 19 deletions
  1. 20 19
      pollution.ipynb

+ 20 - 19
pollution.ipynb

@@ -96,11 +96,11 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 70,
+   "execution_count": null,
    "metadata": {},
    "outputs": [],
    "source": [
-    "%config InlineBackend.figure_format ='retina'"
+    "%config InlineBackend.figure_format = 'retina'"
    ]
   },
   {
@@ -109,15 +109,13 @@
    "metadata": {},
    "outputs": [],
    "source": [
-    "ax = world[(world.continent == 'Europe')].plot(\n",
-    "    edgecolor='black',\n",
-    "    color='white',\n",
-    "    figsize=(20, 12),\n",
-    ")\n",
-    "ax.set_xlim(-28, 32)\n",
-    "ax.set_ylim(32, 75)\n",
-    "ax.set_title('E-PRTR_database_v17_xls.zip / Pollutant releases.xlsx / 2011')\n",
-    "pollutant_releases_geo[pollutant_releases_geo.ReportingYear == 2011].plot(ax=ax, markersize=0.1);"
+    "european_facilities_2011 = geopandas.GeoDataFrame(pollutant_releases_geo[\n",
+    "    (pollutant_releases_geo.Long > -28)\n",
+    "    & (pollutant_releases_geo.Long < 32)\n",
+    "    & (pollutant_releases_geo.Lat > 32)\n",
+    "    & (pollutant_releases_geo.Lat < 75)\n",
+    "    & (pollutant_releases_geo.ReportingYear == 2011)\n",
+    "].set_index('FacilityID').groupby('FacilityID').first())"
    ]
   },
   {
@@ -126,12 +124,15 @@
    "metadata": {},
    "outputs": [],
    "source": [
-    "european_facilities = geopandas.GeoDataFrame(pollutant_releases_geo[\n",
-    "    (pollutant_releases_geo.Long > -28)\n",
-    "    & (pollutant_releases_geo.Long < 32)\n",
-    "    & (pollutant_releases_geo.Lat > 32)\n",
-    "    & (pollutant_releases_geo.Lat < 75)\n",
-    "].groupby('FacilityID').first())"
+    "ax = world[(world.continent == 'Europe')].plot(\n",
+    "    edgecolor='black',\n",
+    "    color='white',\n",
+    "    figsize=(20, 12),\n",
+    ")\n",
+    "ax.set_xlim(-28, 32)\n",
+    "ax.set_ylim(32, 75)\n",
+    "ax.set_title('E-PRTR_database_v17_xls.zip / Pollutant releases.xlsx / 2011 / facilities')\n",
+    "european_facilities_2011.plot(ax=ax, markersize=0.1);"
    ]
   },
   {
@@ -143,14 +144,14 @@
     "import geoplot\n",
     "\n",
     "ax = geoplot.kdeplot(\n",
-    "    european_facilities,\n",
+    "    european_facilities_2011,\n",
     "    clip=world.geometry,\n",
     "    shade=True,\n",
     "    cmap='Reds',\n",
     "    projection=geoplot.crs.AlbersEqualArea(),\n",
     "    figsize=(24, 16),\n",
     ")\n",
-    "ax.set_title('E-PRTR_database_v17_xls.zip / Pollutant releases.xlsx / kdeplot')"
+    "ax.set_title('E-PRTR_database_v17_xls.zip / Pollutant releases.xlsx / 2011 / facilities');"
    ]
   }
  ],