├── docs ├── .nojekyll ├── images │ ├── tip.png │ ├── Rlogo.png │ ├── note.png │ ├── caution.png │ ├── sf_logo.gif │ ├── warning.png │ ├── data.table.png │ ├── important.png │ ├── r_qgis_puzzle.png │ ├── venn-clip-1.png │ ├── QGIS_r_intro_5.png │ ├── cartography_example.png │ └── 01_tidyverse_data_science.png ├── libs │ ├── leaflet-1.3.1 │ │ ├── images │ │ │ ├── layers.png │ │ │ ├── layers-2x.png │ │ │ ├── marker-icon.png │ │ │ ├── marker-icon-2x.png │ │ │ └── marker-shadow.png │ │ └── leaflet.css │ ├── gitbook-2.6.7 │ │ ├── css │ │ │ ├── fontawesome │ │ │ │ └── fontawesome-webfont.ttf │ │ │ ├── plugin-table.css │ │ │ ├── plugin-search.css │ │ │ ├── plugin-bookdown.css │ │ │ └── plugin-fontsettings.css │ │ └── js │ │ │ ├── jquery.highlight.js │ │ │ ├── plugin-sharing.js │ │ │ ├── plugin-fontsettings.js │ │ │ ├── plugin-search.js │ │ │ ├── plugin-bookdown.js │ │ │ └── lunr.js │ ├── leaflet-providers-plugin-2.0.2 │ │ └── leaflet-providers-plugin.js │ ├── leafletfix-1.0.0 │ │ └── leafletfix.css │ ├── rstudio_leaflet-1.3.1 │ │ └── rstudio_leaflet.css │ └── Proj4Leaflet-1.0.1 │ │ └── proj4leaflet.js ├── FOSS4G2019_Geoprocessing_with_R_workshop_files │ └── figure-html │ │ ├── ggplot-1.png │ │ ├── theme-1.png │ │ ├── quick_plot-1.png │ │ ├── scale_vidiris-1.png │ │ ├── tmap_polygons-1.png │ │ ├── tmap_sidemaps-1.png │ │ ├── tmap_decorations-1.png │ │ ├── with_cartography-1.png │ │ └── ggplot_multiple_layer-1.png ├── style.css ├── search_index.json ├── references.html └── index.html ├── preamble.tex ├── 06-references.Rmd ├── _bookdown_files ├── FOSS4G2019_Geoprocessing_with_R_workshop_cache │ └── html │ │ ├── nice-fig_15ac5ab5c056a4bc7340a640d858d055.rdb │ │ ├── nice-tab_9fe9d6117b6a923f16c068132c74ab5d.rdb │ │ ├── session_info_7b3623ed836e7d0cfb4572abed2aa607.rdb │ │ ├── unnamed-chunk-1_37de3a22733113362c4678cd745c5c4e.rdb │ │ ├── __packages │ │ ├── nice-fig_15ac5ab5c056a4bc7340a640d858d055.rdx │ │ ├── nice-tab_9fe9d6117b6a923f16c068132c74ab5d.rdx │ │ ├── nice-fig_15ac5ab5c056a4bc7340a640d858d055.RData │ │ ├── nice-tab_9fe9d6117b6a923f16c068132c74ab5d.RData │ │ ├── session_info_7b3623ed836e7d0cfb4572abed2aa607.RData │ │ ├── session_info_7b3623ed836e7d0cfb4572abed2aa607.rdx │ │ ├── unnamed-chunk-1_37de3a22733113362c4678cd745c5c4e.rdx │ │ └── unnamed-chunk-1_37de3a22733113362c4678cd745c5c4e.RData └── FOSS4G2019_Geoprocessing_with_R_workshop_files │ └── figure-html │ ├── theme-1.png │ ├── ggplot-1.png │ ├── nice-fig-1.png │ ├── quick_plot-1.png │ ├── scale_vidiris-1.png │ ├── tmap_polygons-1.png │ ├── tmap_sidemaps-1.png │ ├── unnamed-chunk-1-1.png │ └── tmap_decorations-1.png ├── images ├── tip.png ├── Rlogo.png ├── note.png ├── caution.png ├── sf_logo.gif ├── warning.png ├── data.table.png ├── important.png ├── tidyverse.png ├── r_qgis_puzzle.png ├── venn-clip-1.png ├── QGIS_r_intro_5.png ├── cartography_example.png └── 01_tidyverse_data_science.png ├── foss4g_R_workshop.gpkg ├── Makefile ├── _bookdown.yml ├── FOSS4G2019_Geoprocessing_with_R_workshop.Rproj ├── _output.yml ├── .gitignore ├── 05-summary.Rmd ├── book.bib ├── README.md ├── style.css ├── index.Rmd ├── 01-intro.Rmd ├── packages.bib ├── 02-R_basics.Rmd ├── 04-maps.Rmd ├── 03-geoprocessing.Rmd └── LICENCE.md /docs/.nojekyll: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /preamble.tex: -------------------------------------------------------------------------------- 1 | \usepackage{booktabs} 2 | -------------------------------------------------------------------------------- /06-references.Rmd: -------------------------------------------------------------------------------- 1 | `r if (knitr::is_html_output()) ' 2 | # References {-} 3 | '` 4 | -------------------------------------------------------------------------------- /_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_cache/html/nice-fig_15ac5ab5c056a4bc7340a640d858d055.rdb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_cache/html/nice-tab_9fe9d6117b6a923f16c068132c74ab5d.rdb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/tip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/images/tip.png -------------------------------------------------------------------------------- /_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_cache/html/session_info_7b3623ed836e7d0cfb4572abed2aa607.rdb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/Rlogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/images/Rlogo.png -------------------------------------------------------------------------------- /images/note.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/images/note.png -------------------------------------------------------------------------------- /_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_cache/html/unnamed-chunk-1_37de3a22733113362c4678cd745c5c4e.rdb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/images/tip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/docs/images/tip.png -------------------------------------------------------------------------------- /images/caution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/images/caution.png -------------------------------------------------------------------------------- /images/sf_logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/images/sf_logo.gif -------------------------------------------------------------------------------- /images/warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/images/warning.png -------------------------------------------------------------------------------- /docs/images/Rlogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/docs/images/Rlogo.png -------------------------------------------------------------------------------- /docs/images/note.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/docs/images/note.png -------------------------------------------------------------------------------- /images/data.table.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/images/data.table.png -------------------------------------------------------------------------------- /images/important.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/images/important.png -------------------------------------------------------------------------------- /images/tidyverse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/images/tidyverse.png -------------------------------------------------------------------------------- /docs/images/caution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/docs/images/caution.png -------------------------------------------------------------------------------- /docs/images/sf_logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/docs/images/sf_logo.gif -------------------------------------------------------------------------------- /docs/images/warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/docs/images/warning.png -------------------------------------------------------------------------------- /foss4g_R_workshop.gpkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/foss4g_R_workshop.gpkg -------------------------------------------------------------------------------- /images/r_qgis_puzzle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/images/r_qgis_puzzle.png -------------------------------------------------------------------------------- /images/venn-clip-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/images/venn-clip-1.png -------------------------------------------------------------------------------- /docs/images/data.table.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/docs/images/data.table.png -------------------------------------------------------------------------------- /docs/images/important.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/docs/images/important.png -------------------------------------------------------------------------------- /images/QGIS_r_intro_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/images/QGIS_r_intro_5.png -------------------------------------------------------------------------------- /docs/images/r_qgis_puzzle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/docs/images/r_qgis_puzzle.png -------------------------------------------------------------------------------- /docs/images/venn-clip-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/docs/images/venn-clip-1.png -------------------------------------------------------------------------------- /docs/images/QGIS_r_intro_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/docs/images/QGIS_r_intro_5.png -------------------------------------------------------------------------------- /images/cartography_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/images/cartography_example.png -------------------------------------------------------------------------------- /docs/images/cartography_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/docs/images/cartography_example.png -------------------------------------------------------------------------------- /images/01_tidyverse_data_science.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/images/01_tidyverse_data_science.png -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | render: 2 | Rscript -e "bookdown::render_book('index.Rmd', 'bookdown::gitbook')" 3 | Rscript -e "bookdown::render_book('index.Rmd', 'bookdown::pdf_book')" -------------------------------------------------------------------------------- /docs/images/01_tidyverse_data_science.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/docs/images/01_tidyverse_data_science.png -------------------------------------------------------------------------------- /docs/libs/leaflet-1.3.1/images/layers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/docs/libs/leaflet-1.3.1/images/layers.png -------------------------------------------------------------------------------- /docs/libs/leaflet-1.3.1/images/layers-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/docs/libs/leaflet-1.3.1/images/layers-2x.png -------------------------------------------------------------------------------- /docs/libs/leaflet-1.3.1/images/marker-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/docs/libs/leaflet-1.3.1/images/marker-icon.png -------------------------------------------------------------------------------- /docs/libs/leaflet-1.3.1/images/marker-icon-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/docs/libs/leaflet-1.3.1/images/marker-icon-2x.png -------------------------------------------------------------------------------- /docs/libs/leaflet-1.3.1/images/marker-shadow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/docs/libs/leaflet-1.3.1/images/marker-shadow.png -------------------------------------------------------------------------------- /docs/libs/gitbook-2.6.7/css/fontawesome/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/docs/libs/gitbook-2.6.7/css/fontawesome/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /docs/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/ggplot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/docs/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/ggplot-1.png -------------------------------------------------------------------------------- /docs/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/theme-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/docs/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/theme-1.png -------------------------------------------------------------------------------- /docs/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/quick_plot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/docs/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/quick_plot-1.png -------------------------------------------------------------------------------- /docs/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/scale_vidiris-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/docs/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/scale_vidiris-1.png -------------------------------------------------------------------------------- /docs/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/tmap_polygons-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/docs/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/tmap_polygons-1.png -------------------------------------------------------------------------------- /docs/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/tmap_sidemaps-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/docs/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/tmap_sidemaps-1.png -------------------------------------------------------------------------------- /_bookdown.yml: -------------------------------------------------------------------------------- 1 | book_filename: "FOSS4G2019_Geoprocessing_with_R_workshop" 2 | delete_merged_file: true 3 | output_dir: "docs" 4 | language: 5 | label: 6 | fig: "FIGURE " 7 | tab: "TABLE " 8 | 9 | ui: 10 | chapter_name: "Chapter " 11 | -------------------------------------------------------------------------------- /_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/theme-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/theme-1.png -------------------------------------------------------------------------------- /docs/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/tmap_decorations-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/docs/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/tmap_decorations-1.png -------------------------------------------------------------------------------- /docs/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/with_cartography-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/docs/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/with_cartography-1.png -------------------------------------------------------------------------------- /_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/ggplot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/ggplot-1.png -------------------------------------------------------------------------------- /_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/nice-fig-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/nice-fig-1.png -------------------------------------------------------------------------------- /_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/quick_plot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/quick_plot-1.png -------------------------------------------------------------------------------- /docs/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/ggplot_multiple_layer-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/docs/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/ggplot_multiple_layer-1.png -------------------------------------------------------------------------------- /docs/libs/leaflet-providers-plugin-2.0.2/leaflet-providers-plugin.js: -------------------------------------------------------------------------------- 1 | LeafletWidget.methods.addProviderTiles = function(provider, layerId, group, options) { 2 | this.layerManager.addLayer(L.tileLayer.provider(provider, options), "tile", layerId, group); 3 | }; 4 | -------------------------------------------------------------------------------- /_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/scale_vidiris-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/scale_vidiris-1.png -------------------------------------------------------------------------------- /_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/tmap_polygons-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/tmap_polygons-1.png -------------------------------------------------------------------------------- /_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/tmap_sidemaps-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/tmap_sidemaps-1.png -------------------------------------------------------------------------------- /_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/unnamed-chunk-1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/unnamed-chunk-1-1.png -------------------------------------------------------------------------------- /_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/tmap_decorations-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_files/figure-html/tmap_decorations-1.png -------------------------------------------------------------------------------- /_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_cache/html/__packages: -------------------------------------------------------------------------------- 1 | base 2 | knitr 3 | ggplot2 4 | tidyverse 5 | tibble 6 | tidyr 7 | readr 8 | purrr 9 | dplyr 10 | stringr 11 | forcats 12 | sf 13 | tmap 14 | viridisLite 15 | viridis 16 | ggspatial 17 | mapview 18 | -------------------------------------------------------------------------------- /_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_cache/html/nice-fig_15ac5ab5c056a4bc7340a640d858d055.rdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_cache/html/nice-fig_15ac5ab5c056a4bc7340a640d858d055.rdx -------------------------------------------------------------------------------- /_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_cache/html/nice-tab_9fe9d6117b6a923f16c068132c74ab5d.rdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_cache/html/nice-tab_9fe9d6117b6a923f16c068132c74ab5d.rdx -------------------------------------------------------------------------------- /_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_cache/html/nice-fig_15ac5ab5c056a4bc7340a640d858d055.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_cache/html/nice-fig_15ac5ab5c056a4bc7340a640d858d055.RData -------------------------------------------------------------------------------- /_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_cache/html/nice-tab_9fe9d6117b6a923f16c068132c74ab5d.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_cache/html/nice-tab_9fe9d6117b6a923f16c068132c74ab5d.RData -------------------------------------------------------------------------------- /_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_cache/html/session_info_7b3623ed836e7d0cfb4572abed2aa607.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_cache/html/session_info_7b3623ed836e7d0cfb4572abed2aa607.RData -------------------------------------------------------------------------------- /_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_cache/html/session_info_7b3623ed836e7d0cfb4572abed2aa607.rdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_cache/html/session_info_7b3623ed836e7d0cfb4572abed2aa607.rdx -------------------------------------------------------------------------------- /_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_cache/html/unnamed-chunk-1_37de3a22733113362c4678cd745c5c4e.rdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_cache/html/unnamed-chunk-1_37de3a22733113362c4678cd745c5c4e.rdx -------------------------------------------------------------------------------- /_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_cache/html/unnamed-chunk-1_37de3a22733113362c4678cd745c5c4e.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/HEAD/_bookdown_files/FOSS4G2019_Geoprocessing_with_R_workshop_cache/html/unnamed-chunk-1_37de3a22733113362c4678cd745c5c4e.RData -------------------------------------------------------------------------------- /FOSS4G2019_Geoprocessing_with_R_workshop.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | BuildType: Website 16 | -------------------------------------------------------------------------------- /docs/libs/gitbook-2.6.7/css/plugin-table.css: -------------------------------------------------------------------------------- 1 | .book .book-body .page-wrapper .page-inner section.normal table{display:table;width:100%;border-collapse:collapse;border-spacing:0;overflow:auto}.book .book-body .page-wrapper .page-inner section.normal table td,.book .book-body .page-wrapper .page-inner section.normal table th{padding:6px 13px;border:1px solid #ddd}.book .book-body .page-wrapper .page-inner section.normal table tr{background-color:#fff;border-top:1px solid #ccc}.book .book-body .page-wrapper .page-inner section.normal table tr:nth-child(2n){background-color:#f8f8f8}.book .book-body .page-wrapper .page-inner section.normal table th{font-weight:700} 2 | -------------------------------------------------------------------------------- /_output.yml: -------------------------------------------------------------------------------- 1 | bookdown::gitbook: 2 | css: style.css 3 | config: 4 | toc: 5 | before: | 6 |
  • FOSS4G2019 Geoprocessing with R workshop
  • 7 | after: | 8 |
  • Published with bookdown
  • 9 | download: [] 10 | edit: https://github.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/edit/master/%s 11 | sharing: 12 | github: yes 13 | facebook: no 14 | bookdown::pdf_book: 15 | includes: 16 | in_header: preamble.tex 17 | latex_engine: xelatex 18 | citation_package: natbib 19 | keep_tex: yes 20 | bookdown::epub_book: default 21 | -------------------------------------------------------------------------------- /docs/libs/gitbook-2.6.7/css/plugin-search.css: -------------------------------------------------------------------------------- 1 | .book .book-summary .book-search { 2 | padding: 6px; 3 | background: transparent; 4 | position: absolute; 5 | top: -50px; 6 | left: 0px; 7 | right: 0px; 8 | transition: top 0.5s ease; 9 | } 10 | .book .book-summary .book-search input, 11 | .book .book-summary .book-search input:focus, 12 | .book .book-summary .book-search input:hover { 13 | width: 100%; 14 | background: transparent; 15 | border: 1px solid #ccc; 16 | box-shadow: none; 17 | outline: none; 18 | line-height: 22px; 19 | padding: 7px 4px; 20 | color: inherit; 21 | box-sizing: border-box; 22 | } 23 | .book.with-search .book-summary .book-search { 24 | top: 0px; 25 | } 26 | .book.with-search .book-summary ul.summary { 27 | top: 50px; 28 | } 29 | -------------------------------------------------------------------------------- /docs/libs/leafletfix-1.0.0/leafletfix.css: -------------------------------------------------------------------------------- 1 | /* Work around CSS properties introduced on img by bootstrap */ 2 | img.leaflet-tile { 3 | padding: 0; 4 | margin: 0; 5 | border-radius: 0; 6 | border: none; 7 | } 8 | .info { 9 | padding: 6px 8px; 10 | font: 14px/16px Arial, Helvetica, sans-serif; 11 | background: white; 12 | background: rgba(255,255,255,0.8); 13 | box-shadow: 0 0 15px rgba(0,0,0,0.2); 14 | border-radius: 5px; 15 | } 16 | .legend { 17 | line-height: 18px; 18 | color: #555; 19 | } 20 | .legend svg text { 21 | fill: #555; 22 | } 23 | .legend svg line { 24 | stroke: #555; 25 | } 26 | .legend i { 27 | width: 18px; 28 | height: 18px; 29 | margin-right: 4px; 30 | opacity: 0.7; 31 | display: inline-block; 32 | vertical-align: top; 33 | /*For IE 7*/ 34 | zoom: 1; 35 | *display: inline; 36 | } 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | <<<<<<< HEAD 2 | .Rproj.user 3 | .Rhistory 4 | .RData 5 | .Ruserdata 6 | ======= 7 | # History files 8 | .Rhistory 9 | .Rapp.history 10 | 11 | # Session Data files 12 | .RData 13 | 14 | # Example code in package build process 15 | *-Ex.R 16 | 17 | # Output files from R CMD build 18 | /*.tar.gz 19 | 20 | # Output files from R CMD check 21 | /*.Rcheck/ 22 | 23 | # RStudio files 24 | .Rproj.user/ 25 | 26 | # produced vignettes 27 | vignettes/*.html 28 | vignettes/*.pdf 29 | 30 | # OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3 31 | .httr-oauth 32 | 33 | # knitr and R markdown default cache directories 34 | /*_cache/ 35 | /cache/ 36 | 37 | # Temporary files created by R markdown 38 | *.utf8.md 39 | *.knit.md 40 | 41 | # Shiny token, see https://shiny.rstudio.com/articles/shinyapps.html 42 | rsconnect/ 43 | >>>>>>> a6bbcd9fb6df1b71d036bc9ad3e0a09dc2f2955e 44 | -------------------------------------------------------------------------------- /docs/libs/rstudio_leaflet-1.3.1/rstudio_leaflet.css: -------------------------------------------------------------------------------- 1 | .leaflet-tooltip.leaflet-tooltip-text-only, 2 | .leaflet-tooltip.leaflet-tooltip-text-only:before, 3 | .leaflet-tooltip.leaflet-tooltip-text-only:after { 4 | background: none; 5 | border: none; 6 | box-shadow: none; 7 | } 8 | 9 | .leaflet-tooltip.leaflet-tooltip-text-only.leaflet-tooltip-left { 10 | margin-left: 5px; 11 | } 12 | 13 | .leaflet-tooltip.leaflet-tooltip-text-only.leaflet-tooltip-right { 14 | margin-left: -5px; 15 | } 16 | 17 | .leaflet-tooltip:after { 18 | border-right: 6px solid transparent; 19 | /* right: -16px; */ 20 | } 21 | 22 | .leaflet-popup-pane .leaflet-popup-tip-container { 23 | /* when the tooltip container is clicked, it is closed */ 24 | pointer-events: all; 25 | /* tooltips should display the "hand" icon, just like .leaflet-interactive*/ 26 | cursor: pointer; 27 | } 28 | 29 | /* have the widget be displayed in the right 'layer' */ 30 | .leaflet-map-pane { 31 | z-index: auto; 32 | } 33 | -------------------------------------------------------------------------------- /05-summary.Rmd: -------------------------------------------------------------------------------- 1 | # Final Words 2 | 3 | This is just a glimpse what it is possible to do with R for geospatial data analysis. There is more to discover ! You can do spatial analysis and geostatistics like spatial autocorrelation, kriging, etc. If you want to know more about it, please see [Spatial Data Science with R website](https://rspatial.org/analysis/index.html). 4 | 5 | We hope the material does help you get started with R, making it accessible for non staticians or non geographer people (the author is neither of that). R can be use alone as a full GIS, providing tools for data preparation, analysis, mapping and reporting. It can be also use in combination with other GIS tools like GRASS, SAGA or QGIS. 6 | 7 | This document has been made using the **bookdown** package [@R-bookdown] and has been inspired by [Maël Theulière bookdown tutorial "Les données spatiales avec R" (in French)](https://maeltheuliere.github.io/rspatial/index.html) and [Geocomputation with R (Lovelace, Nowosad, Muenchow)](https://geocompr.robinlovelace.net). 8 | 9 | 10 | This book was built with: 11 | 12 | ```{r session_info} 13 | 14 | devtools::session_info() 15 | ``` 16 | -------------------------------------------------------------------------------- /book.bib: -------------------------------------------------------------------------------- 1 | @Book{xie2015, 2 | title = {Dynamic Documents with {R} and knitr}, 3 | author = {Yihui Xie}, 4 | publisher = {Chapman and Hall/CRC}, 5 | address = {Boca Raton, Florida}, 6 | year = {2015}, 7 | edition = {2nd}, 8 | note = {ISBN 978-1498716963}, 9 | url = {http://yihui.name/knitr/}, 10 | } 11 | 12 | @Book{lovelace_geocomputation_2019, 13 | title = {Geocomputation with {{R}}}, 14 | isbn = {1-138-30451-4}, 15 | abstract = {Book on geographic data with R.}, 16 | publisher = {{CRC Press}}, 17 | author = {Lovelace, Robin and Nowosad, Jakub and Muenchow, Jannes}, 18 | year = {2019} 19 | } 20 | 21 | @misc{graserAggregate, 22 | title = {{Aggregate all the things!}}, 23 | year = {2017}, 24 | howpublished = {\url{https://anitagraser.com/2017/06/08/aggregate-all-the-things-qgis-expression-edition/}}, 25 | note = {Accessed: 2019-08-13} 26 | } 27 | 28 | @article{WickamGrammar, 29 | author = {Hadley Wickham}, 30 | title = {A Layered Grammar of Graphics}, 31 | journal = {Journal of Computational and Graphical Statistics}, 32 | volume = {19}, 33 | number = {1}, 34 | pages = {3-28}, 35 | year = {2010}, 36 | publisher = {Taylor & Francis}, 37 | doi = {10.1198/jcgs.2009.07098}, 38 | 39 | URL = { 40 | https://doi.org/10.1198/jcgs.2009.07098 41 | 42 | }, 43 | eprint = { 44 | https://doi.org/10.1198/jcgs.2009.07098 45 | 46 | } 47 | 48 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This is the teaching material for the GeoProcessing with R workshop of FOSS4G 2019 - Bucarest. 2 | 3 | To be ready for the workshop, please install those packages : 4 | 5 | ```r 6 | install.packages("dplyr") 7 | install.packages("sf") 8 | install.packages("spData") 9 | install.packages("here") 10 | install.packages("ggplot2") 11 | install.packages("tmap") 12 | install.packages("cartography") 13 | ``` 14 | 15 | 16 | For [OSGeoLive](https://live.osgeo.org) users, there is already some of them installed in the distribution. 17 | Please start Jupyter Notebooks (Menu -> GeoSpatial -> Spatial Tools -> Jupyter Notebook). It should open a web page. 18 | 19 | Click on `New` in the top right and start a new R Notebook. Then install only the following packages : 20 | 21 | 22 | ```r 23 | install.packages("dplyr") 24 | install.packages("here") 25 | install.packages("tmap") 26 | install.packages("cartography") 27 | ``` 28 | 29 | # Github Pages 30 | 31 | The rendered book is visible with GitHub Pages : 32 | [https://bakaniko.github.io/FOSS4G2019_Geoprocessing_with_R_workshop/](https://bakaniko.github.io/FOSS4G2019_Geoprocessing_with_R_workshop/) 33 | 34 | # Licence 35 | 36 | This material is available on BY-NC-SA licence. 37 | 38 | # Git cloning 39 | 40 | You can clone this repo with this command : 41 | 42 | ``` 43 | git clone https://github.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop/ 44 | ``` 45 | -------------------------------------------------------------------------------- /style.css: -------------------------------------------------------------------------------- 1 | .rmdcaution, .rmdimportant, .rmdnote, .rmdtip, .rmdwarning { 2 | padding: 1em 1em 1em 4em; 3 | margin-bottom: 10px; 4 | background: #f5f5f5 5px center/3em no-repeat; 5 | } 6 | .rmdcaution { 7 | background-image: url("./images/caution.png"); 8 | } 9 | .rmdimportant { 10 | background-image: url("images/important.png"); 11 | } 12 | .rmdnote { 13 | background-image: url("images/note.png"); 14 | } 15 | .rmdtip { 16 | background-image: url("./images/tip.png"); 17 | } 18 | .rmdwarning { 19 | background-image: url("./images/warning.png"); 20 | } 21 | p.caption { 22 | color: #777; 23 | margin-top: 10px; 24 | } 25 | p code { 26 | white-space: inherit; 27 | } 28 | pre { 29 | word-break: normal; 30 | word-wrap: normal; 31 | } 32 | pre code { 33 | white-space: inherit; 34 | } 35 | p.flushright { 36 | text-align: right; 37 | } 38 | blockquote > p:last-child { 39 | text-align: right; 40 | } 41 | blockquote > p:first-child { 42 | text-align: inherit; 43 | } 44 | .header-section-number { 45 | padding-right: .2em; 46 | font-weight: 500; 47 | } 48 | .level1 .header-section-number { 49 | display: inline-block; 50 | border-bottom: 3px solid; 51 | } 52 | .level1 h1 { 53 | border-bottom: 1px solid; 54 | } 55 | h1, h2, h3, h4, h5, h6 { 56 | font-weight: normal; 57 | } 58 | h1.title { 59 | font-weight: 700; 60 | } 61 | .smallcaps { 62 | font-variant: small-caps; 63 | } 64 | .book .book-body .page-wrapper .page-inner section.normal strong { 65 | font-weight: 600; 66 | } 67 | -------------------------------------------------------------------------------- /docs/style.css: -------------------------------------------------------------------------------- 1 | .rmdcaution, .rmdimportant, .rmdnote, .rmdtip, .rmdwarning { 2 | padding: 1em 1em 1em 4em; 3 | margin-bottom: 10px; 4 | background: #f5f5f5 5px center/3em no-repeat; 5 | } 6 | .rmdcaution { 7 | background-image: url("./images/caution.png"); 8 | } 9 | .rmdimportant { 10 | background-image: url("images/important.png"); 11 | } 12 | .rmdnote { 13 | background-image: url("images/note.png"); 14 | } 15 | .rmdtip { 16 | background-image: url("./images/tip.png"); 17 | } 18 | .rmdwarning { 19 | background-image: url("./images/warning.png"); 20 | } 21 | p.caption { 22 | color: #777; 23 | margin-top: 10px; 24 | } 25 | p code { 26 | white-space: inherit; 27 | } 28 | pre { 29 | word-break: normal; 30 | word-wrap: normal; 31 | } 32 | pre code { 33 | white-space: inherit; 34 | } 35 | p.flushright { 36 | text-align: right; 37 | } 38 | blockquote > p:last-child { 39 | text-align: right; 40 | } 41 | blockquote > p:first-child { 42 | text-align: inherit; 43 | } 44 | .header-section-number { 45 | padding-right: .2em; 46 | font-weight: 500; 47 | } 48 | .level1 .header-section-number { 49 | display: inline-block; 50 | border-bottom: 3px solid; 51 | } 52 | .level1 h1 { 53 | border-bottom: 1px solid; 54 | } 55 | h1, h2, h3, h4, h5, h6 { 56 | font-weight: normal; 57 | } 58 | h1.title { 59 | font-weight: 700; 60 | } 61 | .smallcaps { 62 | font-variant: small-caps; 63 | } 64 | .book .book-body .page-wrapper .page-inner section.normal strong { 65 | font-weight: 600; 66 | } 67 | -------------------------------------------------------------------------------- /docs/search_index.json: -------------------------------------------------------------------------------- 1 | [ 2 | ["index.html", "R for Geospatial Processing Chapter 1 Prerequisites 1.1 About this document", " R for Geospatial Processing Nicolas Roelandt 2019-08-27 Chapter 1 Prerequisites This workshop is designed for the attendance of FOSS4G 2019. So basics knowledge in GIS is expected (simple features, projections and CRS, geometrical operations, etc.). No knowledge of R is required. A minimal knowledge of (R)mardown will be a plus to take notes. Please install R on your system and the following libraries. Please follow installation instructions from the CRAN projet. The {sf} library needs several geospatial core libraries (GDAL, GEOS, PROJ) so please follow {sf} installation instructions to be sure to have those. For Ubuntu users, ThinkR published a blogpost about the installation of r 3 5 on Ubuntu 18.04 LTS and tips for spatial packages install.packages("dplyr") install.packages("sf") install.packages("spData") install.packages("here") install.packages("ggplot2") install.packages("tmap") install.packages("cartography") For OSGeoLive users, there is already some of them installed in the distribution. Please start Jupyter Notebooks (Menu -> GeoSpatial -> Spatial Tools -> Jupyter Notebook). It should open a web page. Click on New in the top right and start a new R Notebook. Then install only the following packages : install.packages("dplyr") install.packages("here") install.packages("tmap") install.packages("cartography") 1.1 About this document This document had been written with the R Bookdown package and Rstudio. You can use the editor of your choice to follow the instruction, be careful on the path given by the {here} package. To compile this example to PDF, you need XeLaTeX. You are recommended to install TinyTeX (which includes XeLaTeX): https://yihui.name/tinytex/. You can contribute to this document on GitHub : https://github.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop "] 3 | ] 4 | -------------------------------------------------------------------------------- /docs/libs/gitbook-2.6.7/css/plugin-bookdown.css: -------------------------------------------------------------------------------- 1 | .book .book-header h1 { 2 | padding-left: 20px; 3 | padding-right: 20px; 4 | } 5 | .book .book-header.fixed { 6 | position: fixed; 7 | right: 0; 8 | top: 0; 9 | left: 0; 10 | border-bottom: 1px solid rgba(0,0,0,.07); 11 | } 12 | span.search-highlight { 13 | background-color: #ffff88; 14 | } 15 | @media (min-width: 600px) { 16 | .book.with-summary .book-header.fixed { 17 | left: 300px; 18 | } 19 | } 20 | @media (max-width: 1240px) { 21 | .book .book-body.fixed { 22 | top: 50px; 23 | } 24 | .book .book-body.fixed .body-inner { 25 | top: auto; 26 | } 27 | } 28 | @media (max-width: 600px) { 29 | .book.with-summary .book-header.fixed { 30 | left: calc(100% - 60px); 31 | min-width: 300px; 32 | } 33 | .book.with-summary .book-body { 34 | transform: none; 35 | left: calc(100% - 60px); 36 | min-width: 300px; 37 | } 38 | .book .book-body.fixed { 39 | top: 0; 40 | } 41 | } 42 | 43 | .book .book-body.fixed .body-inner { 44 | top: 50px; 45 | } 46 | .book .book-body .page-wrapper .page-inner section.normal sub, .book .book-body .page-wrapper .page-inner section.normal sup { 47 | font-size: 85%; 48 | } 49 | 50 | @media print { 51 | .book .book-summary, .book .book-body .book-header, .fa { 52 | display: none !important; 53 | } 54 | .book .book-body.fixed { 55 | left: 0px; 56 | } 57 | .book .book-body,.book .book-body .body-inner, .book.with-summary { 58 | overflow: visible !important; 59 | } 60 | } 61 | .kable_wrapper { 62 | border-spacing: 20px 0; 63 | border-collapse: separate; 64 | border: none; 65 | margin: auto; 66 | } 67 | .kable_wrapper > tbody > tr > td { 68 | vertical-align: top; 69 | } 70 | .book .book-body .page-wrapper .page-inner section.normal table tr.header { 71 | border-top-width: 2px; 72 | } 73 | .book .book-body .page-wrapper .page-inner section.normal table tr:last-child td { 74 | border-bottom-width: 2px; 75 | } 76 | .book .book-body .page-wrapper .page-inner section.normal table td, .book .book-body .page-wrapper .page-inner section.normal table th { 77 | border-left: none; 78 | border-right: none; 79 | } 80 | .book .book-body .page-wrapper .page-inner section.normal table.kable_wrapper > tbody > tr, .book .book-body .page-wrapper .page-inner section.normal table.kable_wrapper > tbody > tr > td { 81 | border-top: none; 82 | } 83 | .book .book-body .page-wrapper .page-inner section.normal table.kable_wrapper > tbody > tr:last-child > td { 84 | border-bottom: none; 85 | } 86 | 87 | div.theorem, div.lemma, div.corollary, div.proposition, div.conjecture { 88 | font-style: italic; 89 | } 90 | span.theorem, span.lemma, span.corollary, span.proposition, span.conjecture { 91 | font-style: normal; 92 | } 93 | div.proof:after { 94 | content: "\25a2"; 95 | float: right; 96 | } 97 | .header-section-number { 98 | padding-right: .5em; 99 | } 100 | -------------------------------------------------------------------------------- /index.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "R for Geospatial Processing" 3 | author: "Nicolas Roelandt" 4 | date: "`r Sys.Date()`" 5 | bibliography: 6 | - book.bib 7 | - packages.bib 8 | description: This is the training materials for the **R for Geospatial Processing** 9 | workshop at FOSS4G 2019, Bucarest (Romania). 10 | documentclass: book 11 | link-citations: yes 12 | site: bookdown::bookdown_site 13 | biblio-style: apalike 14 | --- 15 | 16 | # Prerequisites 17 | 18 | This workshop is designed for the attendance of FOSS4G 2019. So basics knowledge in GIS is expected (simple features, projections and CRS, geometrical operations, etc.). 19 | 20 | No knowledge of R is required. A minimal knowledge of [(R)mardown](https://rmarkdown.rstudio.com/) will be a plus to take notes. 21 | 22 | Please install R on your system and the following libraries. 23 | 24 | Please follow installation instructions from the [CRAN projet](https://cran.r-project.org/). 25 | 26 | The {sf} library needs several geospatial core libraries (GDAL, GEOS, PROJ) so please follow [{sf} installation instructions](https://github.com/r-spatial/sf/) to be sure to have those. 27 | 28 | For Ubuntu users, ThinkR published a blogpost about [the installation of r 3 5 on Ubuntu 18.04 LTS and tips for spatial packages](https://rtask.thinkr.fr/installation-of-r-3-5-on-ubuntu-18-04-lts-and-tips-for-spatial-packages/) 29 | 30 | 31 | ```{r needed_libraries, eval=FALSE} 32 | install.packages("dplyr") 33 | install.packages("sf") 34 | install.packages("spData") 35 | install.packages("here") 36 | install.packages("ggplot2") 37 | install.packages("tmap") 38 | install.packages("cartography") 39 | ``` 40 | 41 | For [OSGeoLive](https://live.osgeo.org) users, there is already some of them installed in the distribution. 42 | Please start Jupyter Notebooks (Menu -> GeoSpatial -> Spatial Tools -> Jupyter Notebook). It should open a web page. 43 | 44 | Click on `New` in the top right and start a new R Notebook. Then install only the following packages : 45 | 46 | 47 | ```r 48 | install.packages("dplyr") 49 | install.packages("here") 50 | install.packages("tmap") 51 | install.packages("cartography") 52 | ``` 53 | 54 | ## About this document 55 | 56 | This document had been written with the [R Bookdown package](https://bookdown.org/yihui/bookdown) and [Rstudio](https://www.rstudio.com). You can use the editor of your choice to follow the instruction, be careful on the path given by the {here} package. 57 | 58 | To compile this example to PDF, you need XeLaTeX. You are recommended to install TinyTeX (which includes XeLaTeX): . 59 | 60 | You can contribute to this document on GitHub : 61 | 62 | [https://github.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop](https://github.com/Bakaniko/FOSS4G2019_Geoprocessing_with_R_workshop) 63 | 64 | ```{r setup, eval=T,echo=F,message=F,warning=F} 65 | knitr::opts_chunk$set(cache=T,echo=T,comment="",message=F,warning = F) 66 | # Load packages 67 | library(knitr) 68 | library(ggplot2) 69 | library(here) 70 | library(spData) 71 | library(tidyverse) 72 | library(sf) 73 | library(tmap) 74 | library(ggspatial) 75 | # library(mapview) 76 | theme_set(theme_gray()) 77 | tmap_mode("plot") 78 | ``` 79 | 80 | ```{r include=FALSE} 81 | # automatically create a bib database for R packages 82 | knitr::write_bib(c( 83 | .packages(), 'bookdown', 'knitr', 'rmarkdown' 84 | ), 'packages.bib') 85 | ``` 86 | -------------------------------------------------------------------------------- /docs/libs/gitbook-2.6.7/js/jquery.highlight.js: -------------------------------------------------------------------------------- 1 | gitbook.require(["jQuery"], function(jQuery) { 2 | 3 | /* 4 | * jQuery Highlight plugin 5 | * 6 | * Based on highlight v3 by Johann Burkard 7 | * http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html 8 | * 9 | * Code a little bit refactored and cleaned (in my humble opinion). 10 | * Most important changes: 11 | * - has an option to highlight only entire words (wordsOnly - false by default), 12 | * - has an option to be case sensitive (caseSensitive - false by default) 13 | * - highlight element tag and class names can be specified in options 14 | * 15 | * Copyright (c) 2009 Bartek Szopka 16 | * 17 | * Licensed under MIT license. 18 | * 19 | */ 20 | 21 | jQuery.extend({ 22 | highlight: function (node, re, nodeName, className) { 23 | if (node.nodeType === 3) { 24 | var match = node.data.match(re); 25 | if (match) { 26 | var highlight = document.createElement(nodeName || 'span'); 27 | highlight.className = className || 'highlight'; 28 | var wordNode = node.splitText(match.index); 29 | wordNode.splitText(match[0].length); 30 | var wordClone = wordNode.cloneNode(true); 31 | highlight.appendChild(wordClone); 32 | wordNode.parentNode.replaceChild(highlight, wordNode); 33 | return 1; //skip added node in parent 34 | } 35 | } else if ((node.nodeType === 1 && node.childNodes) && // only element nodes that have children 36 | !/(script|style)/i.test(node.tagName) && // ignore script and style nodes 37 | !(node.tagName === nodeName.toUpperCase() && node.className === className)) { // skip if already highlighted 38 | for (var i = 0; i < node.childNodes.length; i++) { 39 | i += jQuery.highlight(node.childNodes[i], re, nodeName, className); 40 | } 41 | } 42 | return 0; 43 | } 44 | }); 45 | 46 | jQuery.fn.unhighlight = function (options) { 47 | var settings = { className: 'highlight', element: 'span' }; 48 | jQuery.extend(settings, options); 49 | 50 | return this.find(settings.element + "." + settings.className).each(function () { 51 | var parent = this.parentNode; 52 | parent.replaceChild(this.firstChild, this); 53 | parent.normalize(); 54 | }).end(); 55 | }; 56 | 57 | jQuery.fn.highlight = function (words, options) { 58 | var settings = { className: 'highlight', element: 'span', caseSensitive: false, wordsOnly: false }; 59 | jQuery.extend(settings, options); 60 | 61 | if (words.constructor === String) { 62 | words = [words]; 63 | } 64 | words = jQuery.grep(words, function(word, i){ 65 | return word !== ''; 66 | }); 67 | words = jQuery.map(words, function(word, i) { 68 | return word.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); 69 | }); 70 | if (words.length === 0) { return this; } 71 | 72 | var flag = settings.caseSensitive ? "" : "i"; 73 | var pattern = "(" + words.join("|") + ")"; 74 | if (settings.wordsOnly) { 75 | pattern = "\\b" + pattern + "\\b"; 76 | } 77 | var re = new RegExp(pattern, flag); 78 | 79 | return this.each(function () { 80 | jQuery.highlight(this, re, settings.element, settings.className); 81 | }); 82 | }; 83 | 84 | }); 85 | -------------------------------------------------------------------------------- /docs/libs/gitbook-2.6.7/js/plugin-sharing.js: -------------------------------------------------------------------------------- 1 | gitbook.require(["gitbook", "lodash", "jQuery"], function(gitbook, _, $) { 2 | var SITES = { 3 | 'github': { 4 | 'label': 'Github', 5 | 'icon': 'fa fa-github', 6 | 'onClick': function(e) { 7 | e.preventDefault(); 8 | var repo = $('meta[name="github-repo"]').attr('content'); 9 | if (typeof repo === 'undefined') throw("Github repo not defined"); 10 | window.open("https://github.com/"+repo); 11 | } 12 | }, 13 | 'facebook': { 14 | 'label': 'Facebook', 15 | 'icon': 'fa fa-facebook', 16 | 'onClick': function(e) { 17 | e.preventDefault(); 18 | window.open("http://www.facebook.com/sharer/sharer.php?s=100&p[url]="+encodeURIComponent(location.href)); 19 | } 20 | }, 21 | 'twitter': { 22 | 'label': 'Twitter', 23 | 'icon': 'fa fa-twitter', 24 | 'onClick': function(e) { 25 | e.preventDefault(); 26 | window.open("http://twitter.com/home?status="+encodeURIComponent(document.title+" "+location.href)); 27 | } 28 | }, 29 | 'google': { 30 | 'label': 'Google+', 31 | 'icon': 'fa fa-google-plus', 32 | 'onClick': function(e) { 33 | e.preventDefault(); 34 | window.open("https://plus.google.com/share?url="+encodeURIComponent(location.href)); 35 | } 36 | }, 37 | 'linkedin': { 38 | 'label': 'LinkedIn', 39 | 'icon': 'fa fa-linkedin', 40 | 'onClick': function(e) { 41 | e.preventDefault(); 42 | window.open("https://www.linkedin.com/shareArticle?mini=true&url="+encodeURIComponent(location.href)+"&title="+encodeURIComponent(document.title)); 43 | } 44 | }, 45 | 'weibo': { 46 | 'label': 'Weibo', 47 | 'icon': 'fa fa-weibo', 48 | 'onClick': function(e) { 49 | e.preventDefault(); 50 | window.open("http://service.weibo.com/share/share.php?content=utf-8&url="+encodeURIComponent(location.href)+"&title="+encodeURIComponent(document.title)); 51 | } 52 | }, 53 | 'instapaper': { 54 | 'label': 'Instapaper', 55 | 'icon': 'fa fa-instapaper', 56 | 'onClick': function(e) { 57 | e.preventDefault(); 58 | window.open("http://www.instapaper.com/text?u="+encodeURIComponent(location.href)); 59 | } 60 | }, 61 | 'vk': { 62 | 'label': 'VK', 63 | 'icon': 'fa fa-vk', 64 | 'onClick': function(e) { 65 | e.preventDefault(); 66 | window.open("http://vkontakte.ru/share.php?url="+encodeURIComponent(location.href)); 67 | } 68 | } 69 | }; 70 | 71 | 72 | 73 | gitbook.events.bind("start", function(e, config) { 74 | var opts = config.sharing; 75 | if (!opts) return; 76 | 77 | // Create dropdown menu 78 | var menu = _.chain(opts.all) 79 | .map(function(id) { 80 | var site = SITES[id]; 81 | 82 | return { 83 | text: site.label, 84 | onClick: site.onClick 85 | }; 86 | }) 87 | .compact() 88 | .value(); 89 | 90 | // Create main button with dropdown 91 | if (menu.length > 0) { 92 | gitbook.toolbar.createButton({ 93 | icon: 'fa fa-share-alt', 94 | label: 'Share', 95 | position: 'right', 96 | dropdown: [menu] 97 | }); 98 | } 99 | 100 | // Direct actions to share 101 | _.each(SITES, function(site, sideId) { 102 | if (!opts[sideId]) return; 103 | 104 | gitbook.toolbar.createButton({ 105 | icon: site.icon, 106 | label: site.text, 107 | position: 'right', 108 | onClick: site.onClick 109 | }); 110 | }); 111 | }); 112 | }); 113 | -------------------------------------------------------------------------------- /01-intro.Rmd: -------------------------------------------------------------------------------- 1 | # Introduction {#intro} 2 | 3 | R is a programming language dedicated to statistics and data analysis. 4 | 5 | ![R logo](images/Rlogo.png) 6 | 7 | ## Why R ? 8 | 9 | * R is tailor made for data science 10 | * Great for reproductibility (scripts, project) 11 | * Do everything from the analysis to the reporting in one tool (thanks to [Rmarkdown](https://bookdown.org/yihui/rmarkdown/)) 12 | 13 | ### R in GIS 14 | Can we do GIS in R ? Yes ! 15 | 16 | And we can do R in GIS too ! 17 | 18 | #### R spatial 19 | 20 | There is several tools for handling spatial data in R. 21 | Historically, there was {sp}, {rgdal}, {rgeos} as core packages for geospatial data handling and dedicated packages for more advanced processing. 22 | 23 | The {sf} package released a couple years ago is a modernisation of thoses packages. It connects directly to GDAL, GEOS and PROJ libraries and implements the [Simple Features Access](https://en.wikipedia.org/wiki/Simple_Features) into R. It is compatible with the [Tidyverse](https://www.tidyverse.org/) collection of R packages (more on that later). 24 | 25 | ![{sf} logo](images/sf_logo.gif) 26 | 27 | See [r-spatial.github.io/sf](https://r-spatial.github.io/sf/) for more informations about {sf}. 28 | 29 | 30 | #### R in QGIS 31 | 32 | Since Sextante first release, you can use R scripts in QGIS Processing toolbox ! 33 | 34 | ![R script in QGIS](images/QGIS_r_intro_5.png) 35 |

    Use R scripts in Processing.

    36 | 37 | See the [R intro in the official documentation](https://docs.qgis.org/3.4/en/docs/training_manual/processing/r_intro.html) 38 | 39 | #### RQGIS 40 | [RQGIS](https://jannes-m.github.io/RQGIS/index.html) is R package that provides access to QGIS functionnality within the R environnement. 41 | 42 | ![RQGIS](images/r_qgis_puzzle.png) 43 | 44 | ### RSAGA 45 | 46 | There is also the [RSAGA](https://github.com/r-spatial/RSAGA) package to access SAGA processing tools within R. 47 | 48 | ### GRASS 49 | 50 | You can use R in GRASS or GRASS in R too : see the [GRASS wiki](https://grasswiki.osgeo.org/wiki/R_statistics#How_to_use) 51 | 52 | So there is a lot of connexions between R and the GIS world. In the R data science context, it becomes **geodata science** and adds tools to understand and visualize the dataset. 53 | 54 | 55 | ## Base R, Tidyverse and data.table 56 | 57 | 58 | Base R is a set of functions shipped when you install R. Some of those functions were written by different people, not always developers, so even it is powerful it is not homogenous in the syntax or not always efficient (**avoid writing for loops in R**). 59 | 60 | > As a language, R is like French; it has an elegant core, but every rule comes with a set of ad-hoc exceptions that directly contradict it. 61 | http://r.cs.purdue.edu/pub/ecoop12.pdf 62 | 63 | This critisism lead people to create packages to mitigate those issues. 64 | 65 | The Tidyverse is a set of homogenous packages, providing a coherent syntax around verbs (*filter*, *select*, etc) and the possibility to pipe operations. 66 | 67 | ![Tidyverse packages](images/01_tidyverse_data_science.png) 68 |

    Data processing with R tidyverse - Ginolhac and al. 2017.

    69 | 70 | It aims to provide readibility and understanding rather than performance (althought it sometimes provides both). 71 | 72 | The Tidyverse is modular as you can load each packages separatly. We'll use mostly the {dplyr} package in this workshop. 73 | 74 | data.table in the other end was created to be more efficient and can easily [compete with Python Pandas for example](https://h2oai.github.io/db-benchmark/). 75 | data.table can handle very large datasets. Its syntax is close to Python Pandas but less readible by non programmers. 76 | 77 | ![data.table logo](images/data.table.png) 78 | 79 | It is not closed worlds. You can mix all of these in your script like [Suzan Baert](https://suzan.rbind.io/) explained at [SatRday Paris 2019](https://youtu.be/vSU3o3c0-7U?t=1923). 80 | 81 | You can even mix R with Python if you need to with the Rpackage [reticulate](https://rstudio.github.io/reticulate/) or [rpy2](https://rpy2.readthedocs.io). 82 | 83 | This document is based on geodata handling with {sf} and {dplyr} (from the Tidyverse toolset). 84 | 85 | This can be followed on Rstudio or Jupyter R notebook. -------------------------------------------------------------------------------- /docs/libs/gitbook-2.6.7/js/plugin-fontsettings.js: -------------------------------------------------------------------------------- 1 | gitbook.require(["gitbook", "lodash", "jQuery"], function(gitbook, _, $) { 2 | var fontState; 3 | 4 | var THEMES = { 5 | "white": 0, 6 | "sepia": 1, 7 | "night": 2 8 | }; 9 | 10 | var FAMILY = { 11 | "serif": 0, 12 | "sans": 1 13 | }; 14 | 15 | // Save current font settings 16 | function saveFontSettings() { 17 | gitbook.storage.set("fontState", fontState); 18 | update(); 19 | } 20 | 21 | // Increase font size 22 | function enlargeFontSize(e) { 23 | e.preventDefault(); 24 | if (fontState.size >= 4) return; 25 | 26 | fontState.size++; 27 | saveFontSettings(); 28 | }; 29 | 30 | // Decrease font size 31 | function reduceFontSize(e) { 32 | e.preventDefault(); 33 | if (fontState.size <= 0) return; 34 | 35 | fontState.size--; 36 | saveFontSettings(); 37 | }; 38 | 39 | // Change font family 40 | function changeFontFamily(index, e) { 41 | e.preventDefault(); 42 | 43 | fontState.family = index; 44 | saveFontSettings(); 45 | }; 46 | 47 | // Change type of color 48 | function changeColorTheme(index, e) { 49 | e.preventDefault(); 50 | 51 | var $book = $(".book"); 52 | 53 | if (fontState.theme !== 0) 54 | $book.removeClass("color-theme-"+fontState.theme); 55 | 56 | fontState.theme = index; 57 | if (fontState.theme !== 0) 58 | $book.addClass("color-theme-"+fontState.theme); 59 | 60 | saveFontSettings(); 61 | }; 62 | 63 | function update() { 64 | var $book = gitbook.state.$book; 65 | 66 | $(".font-settings .font-family-list li").removeClass("active"); 67 | $(".font-settings .font-family-list li:nth-child("+(fontState.family+1)+")").addClass("active"); 68 | 69 | $book[0].className = $book[0].className.replace(/\bfont-\S+/g, ''); 70 | $book.addClass("font-size-"+fontState.size); 71 | $book.addClass("font-family-"+fontState.family); 72 | 73 | if(fontState.theme !== 0) { 74 | $book[0].className = $book[0].className.replace(/\bcolor-theme-\S+/g, ''); 75 | $book.addClass("color-theme-"+fontState.theme); 76 | } 77 | }; 78 | 79 | function init(config) { 80 | var $bookBody, $book; 81 | 82 | //Find DOM elements. 83 | $book = gitbook.state.$book; 84 | $bookBody = $book.find(".book-body"); 85 | 86 | // Instantiate font state object 87 | fontState = gitbook.storage.get("fontState", { 88 | size: config.size || 2, 89 | family: FAMILY[config.family || "sans"], 90 | theme: THEMES[config.theme || "white"] 91 | }); 92 | 93 | update(); 94 | }; 95 | 96 | 97 | gitbook.events.bind("start", function(e, config) { 98 | var opts = config.fontsettings; 99 | 100 | // Create buttons in toolbar 101 | gitbook.toolbar.createButton({ 102 | icon: 'fa fa-font', 103 | label: 'Font Settings', 104 | className: 'font-settings', 105 | dropdown: [ 106 | [ 107 | { 108 | text: 'A', 109 | className: 'font-reduce', 110 | onClick: reduceFontSize 111 | }, 112 | { 113 | text: 'A', 114 | className: 'font-enlarge', 115 | onClick: enlargeFontSize 116 | } 117 | ], 118 | [ 119 | { 120 | text: 'Serif', 121 | onClick: _.partial(changeFontFamily, 0) 122 | }, 123 | { 124 | text: 'Sans', 125 | onClick: _.partial(changeFontFamily, 1) 126 | } 127 | ], 128 | [ 129 | { 130 | text: 'White', 131 | onClick: _.partial(changeColorTheme, 0) 132 | }, 133 | { 134 | text: 'Sepia', 135 | onClick: _.partial(changeColorTheme, 1) 136 | }, 137 | { 138 | text: 'Night', 139 | onClick: _.partial(changeColorTheme, 2) 140 | } 141 | ] 142 | ] 143 | }); 144 | 145 | 146 | // Init current settings 147 | init(opts); 148 | }); 149 | }); 150 | 151 | 152 | -------------------------------------------------------------------------------- /packages.bib: -------------------------------------------------------------------------------- 1 | @Manual{R-base, 2 | title = {R: A Language and Environment for Statistical Computing}, 3 | author = {{R Core Team}}, 4 | organization = {R Foundation for Statistical Computing}, 5 | address = {Vienna, Austria}, 6 | year = {2018}, 7 | url = {https://www.R-project.org/}, 8 | } 9 | @Manual{R-bookdown, 10 | title = {bookdown: Authoring Books and Technical Documents with R Markdown}, 11 | author = {Yihui Xie}, 12 | year = {2018}, 13 | note = {R package version 0.9}, 14 | url = {https://CRAN.R-project.org/package=bookdown}, 15 | } 16 | @Manual{R-dplyr, 17 | title = {dplyr: A Grammar of Data Manipulation}, 18 | author = {Hadley Wickham and Romain François and Lionel Henry and Kirill Müller}, 19 | year = {2019}, 20 | note = {R package version 0.8.1}, 21 | url = {https://CRAN.R-project.org/package=dplyr}, 22 | } 23 | @Manual{R-forcats, 24 | title = {forcats: Tools for Working with Categorical Variables (Factors)}, 25 | author = {Hadley Wickham}, 26 | year = {2019}, 27 | note = {R package version 0.4.0}, 28 | url = {https://CRAN.R-project.org/package=forcats}, 29 | } 30 | @Manual{R-ggplot2, 31 | title = {ggplot2: Create Elegant Data Visualisations Using the Grammar of Graphics}, 32 | author = {Hadley Wickham and Winston Chang and Lionel Henry and Thomas Lin Pedersen and Kohske Takahashi and Claus Wilke and Kara Woo}, 33 | year = {2018}, 34 | note = {R package version 3.1.0}, 35 | url = {https://CRAN.R-project.org/package=ggplot2}, 36 | } 37 | @Manual{R-ggspatial, 38 | title = {ggspatial: Spatial Data Framework for ggplot2}, 39 | author = {Dewey Dunnington}, 40 | year = {2018}, 41 | note = {R package version 1.0.3}, 42 | url = {https://CRAN.R-project.org/package=ggspatial}, 43 | } 44 | @Manual{R-here, 45 | title = {here: A Simpler Way to Find Your Files}, 46 | author = {Kirill Müller}, 47 | year = {2017}, 48 | note = {R package version 0.1}, 49 | url = {https://CRAN.R-project.org/package=here}, 50 | } 51 | @Manual{R-knitr, 52 | title = {knitr: A General-Purpose Package for Dynamic Report Generation in R}, 53 | author = {Yihui Xie}, 54 | year = {2018}, 55 | note = {R package version 1.21}, 56 | url = {https://CRAN.R-project.org/package=knitr}, 57 | } 58 | @Manual{R-purrr, 59 | title = {purrr: Functional Programming Tools}, 60 | author = {Lionel Henry and Hadley Wickham}, 61 | year = {2019}, 62 | note = {R package version 0.3.2}, 63 | url = {https://CRAN.R-project.org/package=purrr}, 64 | } 65 | @Manual{R-readr, 66 | title = {readr: Read Rectangular Text Data}, 67 | author = {Hadley Wickham and Jim Hester and Romain Francois}, 68 | year = {2018}, 69 | note = {R package version 1.3.1}, 70 | url = {https://CRAN.R-project.org/package=readr}, 71 | } 72 | @Manual{R-rmarkdown, 73 | title = {rmarkdown: Dynamic Documents for R}, 74 | author = {JJ Allaire and Yihui Xie and Jonathan McPherson and Javier Luraschi and Kevin Ushey and Aron Atkins and Hadley Wickham and Joe Cheng and Winston Chang and Richard Iannone}, 75 | year = {2018}, 76 | note = {R package version 1.11}, 77 | url = {https://CRAN.R-project.org/package=rmarkdown}, 78 | } 79 | @Manual{R-sf, 80 | title = {sf: Simple Features for R}, 81 | author = {Edzer Pebesma}, 82 | year = {2019}, 83 | note = {R package version 0.7-4}, 84 | url = {https://CRAN.R-project.org/package=sf}, 85 | } 86 | @Manual{R-spData, 87 | title = {spData: Datasets for Spatial Analysis}, 88 | author = {Roger Bivand and Jakub Nowosad and Robin Lovelace}, 89 | year = {2019}, 90 | note = {R package version 0.3.0}, 91 | url = {https://CRAN.R-project.org/package=spData}, 92 | } 93 | @Manual{R-stringr, 94 | title = {stringr: Simple, Consistent Wrappers for Common String Operations}, 95 | author = {Hadley Wickham}, 96 | year = {2019}, 97 | note = {R package version 1.4.0}, 98 | url = {https://CRAN.R-project.org/package=stringr}, 99 | } 100 | @Manual{R-tibble, 101 | title = {tibble: Simple Data Frames}, 102 | author = {Kirill Müller and Hadley Wickham}, 103 | year = {2019}, 104 | note = {R package version 2.1.3}, 105 | url = {https://CRAN.R-project.org/package=tibble}, 106 | } 107 | @Manual{R-tidyr, 108 | title = {tidyr: Easily Tidy Data with 'spread()' and 'gather()' Functions}, 109 | author = {Hadley Wickham and Lionel Henry}, 110 | year = {2018}, 111 | note = {R package version 0.8.2}, 112 | url = {https://CRAN.R-project.org/package=tidyr}, 113 | } 114 | @Manual{R-tidyverse, 115 | title = {tidyverse: Easily Install and Load the 'Tidyverse'}, 116 | author = {Hadley Wickham}, 117 | year = {2017}, 118 | note = {R package version 1.2.1}, 119 | url = {https://CRAN.R-project.org/package=tidyverse}, 120 | } 121 | @Manual{R-tmap, 122 | title = {tmap: Thematic Maps}, 123 | author = {Martijn Tennekes}, 124 | year = {2019}, 125 | note = {R package version 2.2}, 126 | url = {https://CRAN.R-project.org/package=tmap}, 127 | } 128 | -------------------------------------------------------------------------------- /02-R_basics.Rmd: -------------------------------------------------------------------------------- 1 | # R basics 2 | 3 | How to manipulate data in R ? How to install and load a package ? Let's see.. 4 | 5 | ## Getting some help 6 | 7 | ## Where am I ? 8 | 9 | To get the current directory, use `getwd()` : 10 | 11 | ```{r getwd} 12 | getwd() 13 | ``` 14 | 15 | If you need to change the directory, there is `setwd()` 16 | 17 | ```{r setwd, eval=FALSE} 18 | setwd("path/to/my/directory") 19 | ``` 20 | 21 | 22 | If you use Rstudio, I can only recommand to work with a [project workflow](https://www.tidyverse.org/articles/2017/12/workflow-vs-script/) to avoid path issues on another computer. 23 | 24 | ## Make calculations 25 | 26 | ```{r calculations} 27 | 1+1 28 | 29 | 3 * 4 30 | 31 | 7/3 32 | 33 | 7%%3 # rest of the division 34 | 35 | ``` 36 | ## Arthmetic functions 37 | R provides a lot of arithmetic functions by default : 38 | 39 | ```{r arithmetic_functions} 40 | sqrt(4.0) 41 | abs(-625) 42 | log10(12900) 43 | ``` 44 | 45 | ## Assign values to a variable 46 | 47 | ```{r fruits} 48 | fruits <- c("apples", "pears", "lemons") 49 | fruits 50 | ``` 51 | 52 | 53 | ```{r quantities} 54 | quantities <- c(3, 2, 1) 55 | print(quantities) 56 | ``` 57 | 58 | ```{block2, type='rmdcaution'} 59 | Indices in R start at 1 ! 60 | ``` 61 | 62 | ```{r show_indices} 63 | print(fruits[1]) 64 | print(fruits[0]) # returns nothing 65 | ``` 66 | 67 | ## For loop and print 68 | ### Simple for loop 69 | ```{r print} 70 | for (fruit in fruits) { 71 | print(fruit) 72 | } 73 | ``` 74 | 75 | ### For loop with indices 76 | 77 | ```{r loop_indices} 78 | for (x in seq(length(fruits))) { 79 | print(paste0("I have ", quantities[x]," ", fruits[x],".")) 80 | } 81 | ``` 82 | 83 | ```{block2, type='rmdwarning'} 84 | For loops in R are possible but not memory efficient. 85 | So if you need to walk through a large amount of data, please consider using functions instead. 86 | ``` 87 | ## Data types 88 | 89 | ### Vectors 90 | `fruits` and `quantities` are character and numeric vectors. 91 | 92 | ```{r, vectors} 93 | class(fruits) 94 | class(quantities) 95 | ``` 96 | 97 | Vectors are the most basic R data object. There is six types of atomic vectors: logical, integer, double, complex, character and raw. You can't mix types in vectors. 98 | 99 | ### Dataframes 100 | 101 | Another frequently encountered data type is the **dataframe**. It is a collection data organized by rows and columns. Columns that can be of different types. Rows don't have to unique but having [tidy data](https://cran.r-project.org/web/packages/tidyr/vignettes/tidy-data.html) is known as a good pratice : 102 | 103 | 104 | > 1. Each variable forms a column. 105 | 1. Each observation forms a row. 106 | 1. Each type of observational unit forms a table. 107 | 108 | Good thing is, in GIS, we tend to have tidy data, right ? 109 | 110 | How to create a data frame from our vectors ? 111 | 112 | #### With `cbind.data.frame()` 113 | 114 | 115 | ```{r build_dataframe} 116 | df1 <- cbind.data.frame(fruits, quantities) # column binding 117 | print(df1) 118 | class(df1) 119 | ``` 120 | 121 | 122 | ```{r build_dataframe2} 123 | df2 <- as_data_frame(fruits) # column binding 124 | colnames(df2) <- "fruits" # change column name 125 | print(df2) 126 | class(df2) 127 | ``` 128 | ```{block2, type='rmdnote'} 129 | Tibbles (`tbl` // `tbl_df`) are dataframes on steroids from the tidyverse. 130 | ``` 131 | 132 | ### Add columns to a dataframe 133 | ```{r, add_column_to_df} 134 | 135 | df3 <- cbind(df2, # entry dataframe 136 | quantities, # column with quantities 137 | price = c(4,7,9) # new colum with price 138 | ) 139 | df3 140 | ``` 141 | 142 | 143 | 144 | ### Other datatypes 145 | 146 | * Matrices 147 | * Lists (`list()`) : collection of objects of different kind 148 | 149 | ```{block2, type='rmdcaution'} 150 | List in R are not like lists in Python. 151 | ``` 152 | 153 | ## Filtering / Subsetting 154 | 155 | In R, you can subset your data by value or variable. There is several way to do it, here is some of them. 156 | 157 | 158 | ### Select variables 159 | 160 | ```{r, get_colnames} 161 | names(df3) 162 | ``` 163 | 164 | ```{r select_indices} 165 | df3[, 2:3] 166 | df3[, c("fruits","price")] 167 | df3 %>% # pipe symbol 168 | select(fruits, quantities) # select from dplyr 169 | ``` 170 | 171 | ### Filter values 172 | 173 | ```{r filtering_data} 174 | df3[df3["price"] > 5,] # don't forget the column comma 175 | 176 | df3 %>% 177 | filter(quantities >= 2) 178 | ``` 179 | ### Mixing selection and filtering 180 | 181 | ```{r mix_select_filter} 182 | 183 | df3[df3["price"] > 5, 1] # select the prices > 5 184 | 185 | df3 %>% 186 | filter(price > 5) %>% # filter first 187 | select(fruits) # select second 188 | ``` 189 | 190 | 191 | ## Joins 192 | 193 | Let's create a new dataframe to join 194 | 195 | ```{r df4} 196 | df4 <- cbind.data.frame(fruits = fruits, buyer = c("Sophie", "Marc", "Nathan")) 197 | df4 198 | ``` 199 | 200 | ### Merge 201 | 202 | ```{r merger_left} 203 | merged_df <- merge(x = df3, y = df4, by = "fruits", all = TRUE) # OUTER JOIN 204 | merged_df 205 | ``` 206 | 207 | 208 | See that [answer on StackOverflow](https://stackoverflow.com/questions/1299871/how-to-join-merge-data-frames-inner-outer-left-right) for more details on left, right, inner and outer joins with `merge()`. 209 | 210 | ### Dplyr 211 | 212 | ```{r dplyr_join} 213 | merged_df <- df3 %>% 214 | full_join(df4) ## or full_join(df4, by = "fruits") 215 | 216 | merged_df 217 | ``` 218 | 219 | See the [documentation of {dplyr}](https://dplyr.tidyverse.org/reference/join.html) for more information on joins. 220 | 221 | ## Going further 222 | 223 | If you want to go further in the learning of the R language and the Tidyverse tools, there is a lot of resources online. You might want to start by those : 224 | 225 | * Base R : [R manuals](https://colinfay.me/r-manuals/) 226 | * Tidyverse : [R for Data Science (free ebook)](https://r4ds.had.co.nz) 227 | 228 | 229 | -------------------------------------------------------------------------------- /docs/libs/gitbook-2.6.7/js/plugin-search.js: -------------------------------------------------------------------------------- 1 | gitbook.require(["gitbook", "lodash", "jQuery"], function(gitbook, _, $) { 2 | var index = null; 3 | var $searchInput, $searchLabel, $searchForm; 4 | var $highlighted, hi = 0, hiOpts = { className: 'search-highlight' }; 5 | var collapse = false; 6 | 7 | // Use a specific index 8 | function loadIndex(data) { 9 | // [Yihui] In bookdown, I use a character matrix to store the chapter 10 | // content, and the index is dynamically built on the client side. 11 | // Gitbook prebuilds the index data instead: https://github.com/GitbookIO/plugin-search 12 | // We can certainly do that via R packages V8 and jsonlite, but let's 13 | // see how slow it really is before improving it. On the other hand, 14 | // lunr cannot handle non-English text very well, e.g. the default 15 | // tokenizer cannot deal with Chinese text, so we may want to replace 16 | // lunr with a dumb simple text matching approach. 17 | index = lunr(function () { 18 | this.ref('url'); 19 | this.field('title', { boost: 10 }); 20 | this.field('body'); 21 | }); 22 | data.map(function(item) { 23 | index.add({ 24 | url: item[0], 25 | title: item[1], 26 | body: item[2] 27 | }); 28 | }); 29 | } 30 | 31 | // Fetch the search index 32 | function fetchIndex() { 33 | return $.getJSON(gitbook.state.basePath+"/search_index.json") 34 | .then(loadIndex); // [Yihui] we need to use this object later 35 | } 36 | 37 | // Search for a term and return results 38 | function search(q) { 39 | if (!index) return; 40 | 41 | var results = _.chain(index.search(q)) 42 | .map(function(result) { 43 | var parts = result.ref.split("#"); 44 | return { 45 | path: parts[0], 46 | hash: parts[1] 47 | }; 48 | }) 49 | .value(); 50 | 51 | // [Yihui] Highlight the search keyword on current page 52 | hi = 0; 53 | $highlighted = results.length === 0 ? undefined : $('.page-inner') 54 | .unhighlight(hiOpts).highlight(q, hiOpts).find('span.search-highlight'); 55 | scrollToHighlighted(); 56 | toggleTOC(results.length > 0); 57 | 58 | return results; 59 | } 60 | 61 | // [Yihui] Scroll the chapter body to the i-th highlighted string 62 | function scrollToHighlighted() { 63 | if (!$highlighted) return; 64 | var n = $highlighted.length; 65 | if (n === 0) return; 66 | var $p = $highlighted.eq(hi), p = $p[0], rect = p.getBoundingClientRect(); 67 | if (rect.top < 0 || rect.bottom > $(window).height()) { 68 | ($(window).width() >= 1240 ? $('.body-inner') : $('.book-body')) 69 | .scrollTop(p.offsetTop - 100); 70 | } 71 | $highlighted.css('background-color', ''); 72 | // an orange background color on the current item and removed later 73 | $p.css('background-color', 'orange'); 74 | setTimeout(function() { 75 | $p.css('background-color', ''); 76 | }, 2000); 77 | } 78 | 79 | // [Yihui] Expand/collapse TOC 80 | function toggleTOC(show) { 81 | if (!collapse) return; 82 | var toc_sub = $('ul.summary').children('li[data-level]').children('ul'); 83 | if (show) return toc_sub.show(); 84 | var href = window.location.pathname; 85 | href = href.substr(href.lastIndexOf('/') + 1); 86 | if (href === '') href = 'index.html'; 87 | var li = $('a[href^="' + href + location.hash + '"]').parent('li.chapter').first(); 88 | toc_sub.hide().parent().has(li).children('ul').show(); 89 | li.children('ul').show(); 90 | } 91 | 92 | // Create search form 93 | function createForm(value) { 94 | if ($searchForm) $searchForm.remove(); 95 | if ($searchLabel) $searchLabel.remove(); 96 | if ($searchInput) $searchInput.remove(); 97 | 98 | $searchForm = $('
    ', { 99 | 'class': 'book-search', 100 | 'role': 'search' 101 | }); 102 | 103 | $searchLabel = $('