4 Commits 096360a2b4 ... e313935e6b

Author SHA1 Message Date
  Fabian Peter Hammerle e313935e6b lay pointplot on top of kdeplot 4 years ago
  Fabian Peter Hammerle c6ec0da97e GeoDataFrame.plot -> geoplot.poly/pointplot 4 years ago
  Fabian Peter Hammerle f2fa3ecd56 restrict to year=2011; fix failing aggregation 4 years ago
  Fabian Peter Hammerle f301624f07 increase plot resolution 4 years ago
1 changed files with 19 additions and 14 deletions
  1. 19 14
      pollution.ipynb

+ 19 - 14
pollution.ipynb

@@ -100,15 +100,7 @@
    "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);"
+    "%config InlineBackend.figure_format = 'retina'"
    ]
   },
   {
@@ -117,12 +109,13 @@
    "metadata": {},
    "outputs": [],
    "source": [
-    "european_facilities = geopandas.GeoDataFrame(pollutant_releases_geo[\n",
+    "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",
-    "].groupby('FacilityID').first())"
+    "    & (pollutant_releases_geo.ReportingYear == 2011)\n",
+    "].set_index('FacilityID').groupby('FacilityID').first())"
    ]
   },
   {
@@ -134,14 +127,26 @@
     "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",
+    "    figsize=(20, 12),\n",
+    "    # extent=(-28, 32, 32, 75),\n",
+    ")\n",
+    "geoplot.polyplot(\n",
+    "    world.geometry,\n",
+    "    ax=ax,\n",
+    "    linewidth=1,\n",
     ")\n",
-    "ax.set_title('E-PRTR_database_v17_xls.zip / Pollutant releases.xlsx / kdeplot')"
+    "geoplot.pointplot(\n",
+    "    european_facilities_2011,\n",
+    "    color='orange',\n",
+    "    s=0.4,\n",
+    "    ax=ax,\n",
+    ");\n",
+    "ax.set_title('E-PRTR_database_v17_xls.zip / Pollutant releases.xlsx / 2011 / facilities');"
    ]
   }
  ],