diff --git a/README.Rmd b/README.Rmd index 0c7c76333..c34b0031f 100644 --- a/README.Rmd +++ b/README.Rmd @@ -92,10 +92,39 @@ Many thanks to all contributors to the book so far via GitHub (this list will up 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`](https://github.com/Robinlovelace/geocompr/blob/main/misc/our-impact.csv). -## Reproducing the book +## Downloading the source code + +The recommended way to get the source code underlying Geocomputation with R on your computer is by cloning the repo. +You can can that on any computer with [Git](https://github.com/git-guides/install-git) installed with the following command: + +```bash +git clone https://github.com/Robinlovelace/geocompr.git +``` + +An alternative approach, which we recommend for people who want to contribute to open source projects hosted on GitHub, is to install the [`gh` CLI tool](https://github.com/cli/cli#installation). +From there cloning a fork of the source code, that you can change and share (including with Pull Requests to improve the book), can be done with the following command: + +```bash +git fork robinlovelace/geocompr # (git clone robinlovelace/geocompr # also works) +``` + +Both of those methods require you to have Git installed. +If not, you can download the book's source code from the URL https://github.com/Robinlovelace/geocompr/archive/refs/heads/main.zip . +Download/unzip the source code from the R command line to increase reproducibility and reduce time spent clicking around: + +```{r dl-unzip, eval=FALSE} +u = "https://github.com/Robinlovelace/geocompr/archive/refs/heads/main.zip" +f = basename(u) +download.file(u, f) # download the file +unzip(f) # unzip it +file.rename(f, "geocompr") # rename the directory +rstudioapi::openProject("geococompr") +``` + +## Reproducing the book in R/RStudio To ease reproducibility, we created the `geocompkg` package. -Installing it from GitHub will install all the R packages needed build the book (you will need a computer with necessary [system dependencies](https://github.com/r-spatial/sf#installing) and the [**remotes**](https://github.com/r-lib/remotes/) package installed): +Install it with the following commands: ```{r readme-install-github, eval=FALSE} install.packages("remotes") @@ -103,8 +132,11 @@ install.packages("remotes") remotes::install_github("geocompr/geocompkg") ``` -Running the commands above should install the packages needed to run the first part of the book (chapters 1 to 8). -To install and build the book in its entirety, run the following command (which installs additional 'Suggests' packages, this may take some time to run!): +Installing `geocompkg` will also install core packages required for reproducing **Part 1 of the book** (chapters 1 to 8). +Note: you may also need to install [system dependencies](https://github.com/r-spatial/sf#installing) if you're running Linux (recommended) or Mac operating systems. +You also need to have the [**remotes**](https://github.com/r-lib/remotes/) package installed: + +To reproduce book **in its entirety**, run the following command (which installs additional 'Suggests' packages, this may take some time to run!): ```{r readme-install-github-2, message=FALSE, eval=FALSE, results='hide'} # To reproduce all chapters (install lots of packages, may take some time!) @@ -113,10 +145,12 @@ remotes::install_github("geocompr/geocompkg", dependencies = TRUE) 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](https://github.com/r-spatial/sf) for information on that. - -Once the dependencies have been installed you should be able to build and view a local version the book with: +After the dependencies have been installed you should be able to build and view a local version the book with: ```{r readme-render-book, eval=FALSE} +# Change this depending on where you have the book code stored: +rstudioapi::openProject("~/Downloads/geocompr") + # or code //geocompr in the system terminal bookdown::render_book("index.Rmd") # to build the book browseURL("_book/index.html") # to view it ```