Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

intro tweaks2 #984

Merged
merged 12 commits into from
Sep 8, 2023
2 changes: 1 addition & 1 deletion .binder/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM geocompr/geocompr:binder
FROM ghcr.io/geocompx/docker:binder

## Declares build arguments
ARG NB_USER
Expand Down
26 changes: 17 additions & 9 deletions 01-introduction.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
# Introduction {#intro}

This book is about using the power of computers to *do things* with geographic data.
It teaches a range of spatial skills, including: reading, writing and manipulating geographic data; making static and interactive maps; applying geocomputation\index{geocomputation} to support more evidence-based decision making; and modeling a range of geographic phenomena, from ecosystems to transport systems.
It teaches a range of spatial skills, including: reading, writing and manipulating geographic file formats; making static and interactive maps; and applying geocomputation\index{geocomputation} to support more evidence-based decision making related to a range of geographic phenomena, from ecosystems to transport systems.
By demonstrating how various geographic operations can be linked, in 'code chunks' that intersperse the prose, the book also teaches reproducible, open and thus scientific workflows.

Learning how to use the wealth of *existing tools* for geocomputation can be exciting.
Creating *new tools* can be truly liberating.
The approach we teach throughout, and programming techniques covered in Chapter \@ref(algorithms)\index{algorithm}, can remove constraints on your creativity imposed by software.
The book is not just about using the wealth of *existing tools* for geocomputation: it's also about understanding the structure of geographic datasets and software from processing them, and enabling the development *new tools*.
The approach we teach throughout, and programming techniques covered in Chapter \@ref(algorithms)\index{algorithm} in particular, can remove constraints on your creativity imposed by software.
After reading the book and completing the exercises you should feel empowered with a strong understanding of the possibilities opened up by R's\index{R} impressive geographic capabilities.
We aim to give you the confidence to use geocomputation to tackle real-world problems, inspire you to communicate your work with maps and reproducible code, and equip you to participate in reproducible research, free software and other communities building and using geographic tools for social and environmental good.
By the end of the book we hope you will be ready to apply your skills tackle real-world problems, to communicate your work in maps and reproducible code, and to participate in reproducible research and free software communities.

Over the last few decades free and open source software for geospatial (FOSS4G\index{FOSS4G}) has progressed at an astonishing rate.
Thanks to organizations such as OSGeo, geographic data analysis is no longer the preserve of those with expensive hardware and software: anyone can now download and run high-performance spatial libraries.
Thanks to organizations such as OSGeo, advanced geographic techniques are no longer the preserve of those with expensive hardware and software: anyone can now download and run high-performance software for geocomputation.
Open source Geographic Information Systems (GIS\index{GIS}), such as [QGIS](http://qgis.org/en/site/)\index{QGIS}, have made geographic analysis accessible worldwide.
GIS programs tend to emphasize graphical user interfaces\index{graphical user interface} (GUIs), with the unintended consequence of discouraging reproducibility\index{reproducibility} (although many can be used from the command line as we'll see in Chapter \@ref(gis)).
R, by contrast, emphasizes the command line interface\index{command-line interface} (CLI).
GIS software products such as QGIS are powerful, but tend to emphasize a graphical user interface\index{graphical user interface} (GUI) approach over the command-line interface (CLI) approach advocated in this book.
The 'GUI-focus' of many GIS products has unintended consequence of disabling many users from making their work full reproducible,\index{reproducibility} a problem that can be overcome by calling 'geoalgorithms' contained in GIS software from the command line, as we'll see in Chapter \@ref(gis)).
A simplistic comparison between the different approaches is illustrated in Table \@ref(tab:gdsl).


```{r gdsl, echo=FALSE, message=FALSE}
d = readr::read_csv("extdata/gis-vs-gds-table.csv")
knitr::kable(x = d,
Expand All @@ -31,7 +31,15 @@ knitr::kable(x = d,
booktabs = TRUE)
```

This book is motivated by the importance of reproducibility\index{reproducibility} for scientific research (see the note below).
R is not the only language providing a CLI for geocomputation.
Other command environments with powerful geographic capabilities exist, including Python/IPython, Julia, and JavaScript.
We encourage curious readers to give them a try and to reproduce the examples in this book in other languages, perhaps with reference to the book [Geocomputation with Python](https://py.geocompx.org/), the open access version of which is also hosted on [geocompx.org](https://geocompx.org/).
However, R has some advantages that make it well-suited to geocomputation.
The 'R-spatial stack' is easy to install, has comprehensive and well-maintained core packages meaning less 'context switching' and more focus on techniques rather than getting the code working.
R has 'batteries included' with statistical functions as part of the base installation and hundreds of well-mainted packages implementing many cutting edge methods.
With R, you can dive and get things working with surprisingly few lines of code, and generate publication quality interactive maps thanks to excellent mapping packages, as outlined in Chapter \@ref(adv-map).

This book is also motivated by the importance of reproducibility\index{reproducibility} for scientific research.
It aims to make reproducible geographic data analysis\index{geographic data analysis} workflows more accessible, and demonstrate the power of open geospatial software available from the command-line.
"Interfaces to other software are part of R" [@eddelbuettel_extending_2018].
This means that in addition to outstanding 'in house' capabilities, R allows access to many other spatial software libraries, explained in Section \@ref(why-use-r-for-geocomputation) and demonstrated in Chapter \@ref(gis).
Expand Down
6 changes: 3 additions & 3 deletions 02-spatial-data.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ For workflows that depend on the legacy class system, `sf` objects can be conver
library(sp)
world_sp = as(world, "Spatial") # from an sf object to sp
# sp functions ...
world_sf = st_as_sf(world_sp) # from sp to sf
world_sf = st_as_sf(world_sp) # from sp to sf
```

### Basic map making {#basic-map}
Expand Down Expand Up @@ -1034,14 +1034,14 @@ The `[[` and `$` operators can also be used to select layers, for example with c
]
It accepts a layer number or its name as the second argument:

```{r}
```{r, eval=FALSE}
multi_rast3 = subset(multi_rast, 3)
multi_rast4 = subset(multi_rast, "landsat_4")
```

The opposite operation, combining several `SpatRaster` objects into one, can be done using the `c` function:

```{r}
```{r, eval=FALSE}
multi_rast34 = c(multi_rast3, multi_rast4)
```

Expand Down
4 changes: 2 additions & 2 deletions code/09-urban-animation.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ m_save = tm_shape(world2) +
tm_symbols(size = "population_millions", size.legend = tm_legend(title = "Population (m)"),
fill = "red", fill_alpha = 0.5) +
tm_facets(by = "year", nrow = 1, ncol = 1, free.coords = FALSE)
tmap:::tmap_animation(tm = m_save, filename = "/tmp/urban-animated.gif", width = 1200, height = 800)
magick::image_read("/tmp/urban-animated.gif")
tmap::tmap_animation(tm = m_save, filename = "/tmp/urban-animated.gif", width = 1200, height = 800)
# magick::image_read("/tmp/urban-animated.gif")
61 changes: 0 additions & 61 deletions code/old-to-future-remove/04_spatial_incongruence.R

This file was deleted.

Loading