{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "!curl --location --remote-name --remote-header-name \\\n", " http://ftp.eea.europa.eu/www/eprtr/v17/E-PRTR_database_v17_xls.zip" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "!unzip E-PRTR_database_v17_xls.zip 'Pollutant releases.xlsx'" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import pandas\n", "\n", "pollutant_releases = pandas.read_excel('Pollutant releases.xlsx')\n", "pollutant_releases.head()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import geopandas\n", "\n", "# http://geopandas.org/gallery/create_geopandas_from_pandas.html\n", "pollutant_releases_geo = geopandas.GeoDataFrame(\n", " pollutant_releases[[\n", " 'FacilityID', 'Lat', 'Long', 'ReportingYear', 'PollutantName', \n", " 'PollutantGroupName', 'TotalQuantity', 'TotalQuantity',\n", " ]],\n", " geometry=geopandas.points_from_xy(\n", " pollutant_releases['Long'],\n", " pollutant_releases['Lat'],\n", " ),\n", ")\n", "for column_name in pollutant_releases_geo.select_dtypes('object'):\n", " pollutant_releases_geo[column_name] = pollutant_releases_geo[column_name].astype('category')\n", "pollutant_releases_geo.head()" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "RangeIndex: 652351 entries, 0 to 652350\n", "Data columns (total 9 columns):\n", "FacilityID 652351 non-null int64\n", "Lat 652351 non-null float64\n", "Long 652351 non-null float64\n", "ReportingYear 652351 non-null int64\n", "PollutantName 652351 non-null category\n", "PollutantGroupName 652351 non-null category\n", "TotalQuantity 652351 non-null float64\n", "TotalQuantity 652351 non-null float64\n", "geometry 652351 non-null geometry\n", "dtypes: category(2), float64(4), geometry(1), int64(2)\n", "memory usage: 36.1 MB\n" ] } ], "source": [ "pollutant_releases_geo.info()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "world = geopandas.read_file(geopandas.datasets.get_path('naturalearth_lowres'))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%config InlineBackend.figure_format = 'retina'" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "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())" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import geoplot\n", "\n", "ax = geoplot.kdeplot(\n", " european_facilities_2011,\n", " clip=world.geometry,\n", " shade=True,\n", " cmap='Reds',\n", " projection=geoplot.crs.AlbersEqualArea(),\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", "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');" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.9" } }, "nbformat": 4, "nbformat_minor": 2 }