Sign inSign up

robinlovelace/geocompr

By robinlovelace

Updated about 5 years ago

Docker instance with everything you need to run the code in this book.

Image
4

10K+

robinlovelace/geocompr repository overview

Geocomputation with R

Launch Rstudio
Binder Launch Rstudio
Cloud Actions Docker DOI

Introduction

This repository hosts the code underlying Geocomputation with R, a book by Robin Lovelace, Jakub Nowosad, and Jannes Muenchow:

Lovelace, Robin, Jakub Nowosad and Jannes Muenchow (2019). Geocomputation with R. The R Series. CRC Press.

This book has been published by CRC Press in the R Series. The online version of this book is free to read at https://geocompr.robinlovelace.net/.

Contributing

We encourage contributions on any part of the book, including:

  • improvements to the text, e.g. clarifying unclear sentences, fixing typos (see guidance from Yihui Xie);
  • changes to the code, e.g. to do things in a more efficient way; and
  • suggestions on content (see the project’s issue tracker).

See our-style.md for the book’s style.

Many thanks to all contributors to the book so far via GitHub (this list will update automatically): prosoitos, florisvdh, katygregg, rsbivand, KiranmayiV, erstearns, zmbc, eyesofbambi, nickbearman, tyluRp, giocomai, LaurieLBaker, mdsumner, pat-s, gisma, ateucher, annakrystalli, DarrellCarvalho, kant, gavinsimpson, Henrik-P, Himanshuteli, yutannihilation, jbixon13, yvkschaefer, katiejolly, KHwong12, layik, mtennekes, mvl22, ganes1410, richfitz, SymbolixAU, wdearden, yihui, chihinl, cshancock, gregor-d, jasongrahn, p-kono, pokyah, schuetzingit, sdesabbata, tim-salabim, tszberkowitz.

During the project we aim to contribute ‘upstream’ to the packages that make geocomputation with R possible. This impact is recorded in our-impact.csv.

Reproducing the book

To ease reproducibility, we created the geocompkg package. Installing it from GitHub will install all the R packages needed build the book (you will a computer with necessary system dependencies and the remotes package installed):

install.packages("remotes")
remotes::install_github("geocompr/geocompkg")

You need a recent version of the GDAL, GEOS, PROJ and UDUNITS libraries installed for this to work on Mac and Linux. See the sf package’s README for information on that.

Once the dependencies have been installed you should be able to build and view a local version the book with:

bookdown::render_book("index.Rmd") # to build the book
browseURL("_book/index.html") # to view it

Geocompr in binder

For many people the quickest way to get started with Geocomputation with R is in your web browser via Binder. To see an interactive RStudio Server instance click on the following button, which will open mybinder.org with an R installation that has all the dependencies needed to reproduce the book:

Launch Rstudio
Binder

You can also have a play with the repo in RStudio Cloud by clicking on this link (requires log-in):

Launch Rstudio
Cloud

Geocomputation with R in a Docker container

To ease reproducibility we have made Docker images available, at geocompr/geocompr on DockerHub. These images allow you to explore Geocomputation with R in a virtual machine that has up-to-date dependencies.

After you have installed docker and set-it up on your computer you can start RStudio Server without a password (see the Rocker project for info on how to add a password and other security steps for public-facing servers):

docker run -p 8787:8787 -e DISABLE_AUTH=TRUE geocompr/geocompr

If it worked you should be able to open-up RStudio server by opening a browser and navigating to http://localhost:8787/ resulting in an up-to-date version of R and RStudio running in a container.

Start a plain R session running:

docker run -it geocompr/geocompr R

See the geocompr/docker repo for details, including how to share volumes between your computer and the Docker image, for using geographic R packages on your own data and for information on available tags.

Reproducing this README

To reduce the book’s dependencies, scripts to be run infrequently to generate input for the book are run on creation of this README.

The additional packages required for this can be installed as follows:

source("code/extra-pkgs.R")

With these additional dependencies installed, you should be able to run the following scripts, which create content for the book, that we’ve removed from the main book build to reduce package dependencies and the book’s build time:

source("code/cranlogs.R")
source("code/sf-revdep.R")
source("code/08-urban-animation.R")
source("code/08-map-pkgs.R")

Note: the .Rproj file is configured to build a website not a single page. To reproduce this README use the following command:

rmarkdown::render("README.Rmd", output_format = "github_document", output_file = "README.md")

Citations

To cite packages used in this book we use code from Efficient R Programming:

# geocompkg:::generate_citations()

This generates .bib and .csv files containing the packages. The current of packages used can be read-in as follows:

pkg_df = readr::read_csv("extdata/package_list.csv")

Other citations are stored online using Zotero.

If you would like to add to the references, please use Zotero, join the open group add your citation to the open geocompr library.

We use the following citation key format:

[auth:lower]_[veryshorttitle:lower]_[year]

This can be set from inside Zotero desktop with the Better Bibtex plugin installed (see github.com/retorquere/zotero-better-bibtex) by selecting the following menu options (with the shortcut Alt+E followed by N), and as illustrated in the figure below:

Edit > Preferences > Better Bibtex

Zotero settings: these are useful if you want to add references.

We use Zotero because it is a powerful open source reference manager that integrates well with the citr package. As described in the GitHub repo Robinlovelace/rmarkdown-citr-demo.

References

# remotes::install_github("gadenbuie/regexplain")
# regexplain::regexplain_file("extdata/package_list.csv")
pattern = " \\[[^\\}]*\\]" # perl=TRUE
pkg_df$Title = gsub(pattern = pattern, replacement = "", x = pkg_df$Title, perl = TRUE)
knitr::kable(pkg_df)
NameTitleversion
bookdownAuthoring Books and Technical Documents with R Markdown0.7
cartogramCreate Cartograms with R0.1.0
dismoSpecies Distribution Modeling1.1.4
geosphereSpherical Trigonometry1.5.7
ggmapSpatial Visualization with ggplot22.6.1
ggplot2Create Elegant Data Visualisations Using the Grammar of Graphics3.0.0.9000
gstatSpatial and Spatio-Temporal Geostatistical Modelling, Prediction1.1.6
historydataDatasets for Historians0.2.9001
htmlwidgetsHTML Widgets for R1.2
kableExtraConstruct Complex Table with ‘kable’ and Pipe Syntax0.9.0
kernlabKernel-Based Machine Learning Lab0.9.26
knitrA General-Purpose Package for Dynamic Report Generation in R1.20
latticeExtraExtra Graphical Utilities Based on Lattice0.6.28
leafletCreate Interactive Web Maps with the JavaScript ‘Leaflet’2.0.1
link2GILinking Geographic Information Systems, Remote Sensing and Other0.3.0
lwgeomBindings to Selected ‘liblwgeom’ Functions for Simple Features0.1.4
mapviewInteractive Viewing of Spatial Data in R2.4.0
microbenchmarkAccurate Timing Functions1.4.4
mlrMachine Learning in R2.12.1
osmdataImport ‘OpenStreetMap’ Data as Simple Features or Spatial0.0.7
pROCDisplay and Analyze ROC Curves1.12.1
rangerA Fast Implementation of Random Forests0.10.1
rasterGeographic Data Analysis and Modeling2.6.7
rcartocolor‘CARTOColors’ Palettes0.0.22
rgdalBindings for the ‘Geospatial’ Data Abstraction Library1.3.3
rgeosInterface to Geometry Engine - Open Source (‘GEOS’)0.3.28
rgrass7Interface Between GRASS 7 Geographical Information System and R0.1.10
rmapshaperClient for ‘mapshaper’ for ‘Geospatial’ Operations0.4.0
rmarkdownDynamic Documents for R1.10
rnaturalearthWorld Map Data from Natural Earth0.2.0
rnaturalearthdataWorld Vector Map Data from Natural Earth Used in ‘rnaturalearth’0.1.0
RPostgreSQLR Interface to the ‘PostgreSQL’ Database System0.6.2
RQGISIntegrating R with QGIS1.0.3
RSAGASAGA Geoprocessing and Terrain Analysis1.1.0
sfSimple Features for R0.6.3
spClasses and Methods for Spatial Data1.3.1
spDataDatasets for Spatial Analysis0.2.9.0
spDataLargeLarge datasets for spatial analysis0.2.7.0
stplanrSustainable Transport Planning0.2.4.9000
tabularasterTidy Tools for ‘Raster’ Data0.5.0
tidyverseEasily Install and Load the ‘Tidyverse’1.2.1
tmapThematic Maps2.0.1
tmaptoolsThematic Map Tools2.0.1
treeClassification and Regression Trees1.0.39
veganCommunity Ecology Package2.5.2

Tag summary

Content type

Image

Digest

Size

2 GB

Last updated

about 5 years ago

docker pull robinlovelace/geocompr