Browse Source

added dockerfile: jupyter notebook, IRkernel & eurostat

Fabian Peter Hammerle 4 years ago
parent
commit
49f564a2af

+ 48 - 0
eurostat-geospatial/Dockerfile

@@ -0,0 +1,48 @@
+# # https://hub.docker.com/layers/jupyter/r-notebook/7a0c7325e470/images/sha256-4bfbe56214c89bb4e5975ed6ed3837b29d348c524669b4e2328c1487b7822e5b
+# FROM jupyter/r-notebook@sha256:4bfbe56214c89bb4e5975ed6ed3837b29d348c524669b4e2328c1487b7822e5b
+#
+# # RUN conda install udunits2
+#
+# USER 0
+# RUN apt-get update \
+#     && sudo apt-get install --yes --no-install-recommends \
+#         libgdal-dev \
+#         libudunits2-dev
+#
+# USER 1000
+
+FROM debian:bullseye-slim
+
+RUN apt-get update \
+    && apt-get install --yes --no-install-recommends \
+        jupyter-notebook \
+        r-cran-irkernel \
+        `# https://github.com/rOpenGov/eurostat/blob/master/DESCRIPTION` \
+        r-cran-broom \
+        r-cran-classint \
+        r-cran-dplyr \
+        r-cran-httr \
+        r-cran-jsonlite \
+        r-cran-rcolorbrewer \
+        r-cran-readr \
+        r-cran-sf \
+        r-cran-sp \
+        r-cran-stringi \
+        r-cran-stringr \
+        r-cran-tibble \
+        r-cran-tidyr
+
+# TODO merge
+RUN apt-get install --yes --no-install-recommends \
+        `# https://cran.r-project.org/web/packages/RefManageR/index.html ` \
+        r-cran-bibtex \
+        r-cran-lubridate \
+        r-cran-xml2
+
+RUN useradd --create-home --groups staff notebook
+USER notebook
+
+RUN Rscript -e 'install.packages("eurostat")'
+
+WORKDIR /home/notebook
+CMD ["jupyter", "notebook", "--ip=0.0.0.0"]

+ 9 - 0
eurostat-geospatial/docker-compose.yml

@@ -0,0 +1,9 @@
+version: '3'
+
+services:
+  notebook:
+    build: .
+    ports: ['127.0.0.1:8888:8888']
+    security_opt: ['no-new-privileges']
+
+# https://docs.docker.com/compose/compose-file

+ 85 - 0
eurostat-geospatial/download.ipynb

@@ -0,0 +1,85 @@
+{
+ "cells": [
+  {
+   "cell_type": "code",
+   "execution_count": 1,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stderr",
+     "output_type": "stream",
+     "text": [
+      "\n",
+      "COPYRIGHT NOTICE\n",
+      "\n",
+      "When data downloaded from this page \n",
+      "<http://ec.europa.eu/eurostat/web/gisco/geodata/reference-data/administrative-units-statistical-units>\n",
+      "is used in any printed or electronic publication, \n",
+      "in addition to any other provisions \n",
+      "applicable to the whole Eurostat website, \n",
+      "data source will have to be acknowledged \n",
+      "in the legend of the map and \n",
+      "in the introductory page of the publication \n",
+      "with the following copyright notice:\n",
+      "\n",
+      "- EN: (C) EuroGeographics for the administrative boundaries\n",
+      "- FR: (C) EuroGeographics pour les limites administratives\n",
+      "- DE: (C) EuroGeographics bezuglich der Verwaltungsgrenzen\n",
+      "\n",
+      "For publications in languages other than \n",
+      "English, French or German, \n",
+      "the translation of the copyright notice \n",
+      "in the language of the publication shall be used.\n",
+      "\n",
+      "If you intend to use the data commercially, \n",
+      "please contact EuroGeographics for \n",
+      "information regarding their licence agreements.\n",
+      "          \n",
+      "No encoding supplied: defaulting to UTF-8.\n",
+      "\n",
+      "# --------------------------\n",
+      "HEADS UP!!\n",
+      "\n",
+      "Function now returns the data in 'sf'-class (simple features) \n",
+      "by default which is different \n",
+      "from previous behaviour's 'SpatialPolygonDataFrame'. \n",
+      "\n",
+      "If you prefer either 'SpatialPolygonDataFrame' or \n",
+      "fortified 'data_frame' (for ggplot2::geom_polygon), \n",
+      "please specify it explicitly to 'output_class'-argument!\n",
+      "\n",
+      "# --------------------------          \n",
+      "          \n"
+     ]
+    }
+   ],
+   "source": [
+    "library(eurostat)\n",
+    "\n",
+    "shp <- get_eurostat_geospatial(\n",
+    "    output_class=\"spdf\",\n",
+    "    resolution=\"60\",\n",
+    "    nuts_level=3,\n",
+    "    year=2010,\n",
+    ")"
+   ]
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "R",
+   "language": "R",
+   "name": "ir"
+  },
+  "language_info": {
+   "codemirror_mode": "r",
+   "file_extension": ".r",
+   "mimetype": "text/x-r-source",
+   "name": "R",
+   "pygments_lexer": "r",
+   "version": "3.6.1"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}