References

Baddeley, Adrian, Ege Rubak, and Rolf Turner. 2015. Spatial Point Patterns: Methodology and Applications with r. CRC press.
Banerjee, Sudipto, Bradley P Carlin, and Alan E Gelfand. 2014. Hierarchical Modeling and Analysis for Spatial Data. CRC press.
Bivand, Roger S., Edzer Pebesma, and Virgilio Gomez-Rubio. 2013. Applied Spatial Data Analysis with R, Second Edition. Springer, NY. https://asdar-book.org/.
Brunsdon, Chris, and Lex Comber. 2015. An Introduction to r for Spatial Analysis and Mapping. Sage.
Diggle, Peter, and Paulo Justiniano Ribeiro. 2007. Model-Based Geostatistics. Springer.
Dorman, Michael. 2014. Learning r for Geospatial Analysis. Packt Publishing Ltd.
Hengl, Tomislav. 2009. “A Practical Guide to Geostatistical Mapping.”
Hengl, Tomislav, and Robert A MacMillan. 2019. Predictive Soil Mapping with r. Lulu. com.
Lamigueiro, Óscar Perpiñán. 2014. Displaying Time Series, Spatial, and Space-Time Data with r. CRC Press.
Lovelace, Robin, Jakub Nowosad, and Jannes Muenchow. 2019. Geocomputation with r. CRC Press.
Murrell, Paul. 2009. Introduction to Data Technologies. CRC Press.
Plant, Richard E. 2018. Spatial Data Analysis in Ecology and Agriculture Using r. CRC Press.
Wickham, Hadley et al. 2011. “The Split-Apply-Combine Strategy for Data Analysis.” Journal of Statistical Software 40 (1): 1–29.
Wickham, Hadley. 2016. Ggplot2: Elegant Graphics for Data Analysis. Springer. https://ggplot2-book.org/.

  1. https://www.amazon.com/Learning-Geospatial-Analysis-Michael-Dorman/dp/1783984368↩︎

  2. Comprehensive R Archive Network↩︎

  3. https://cran.r-project.org/web/views/Spatial.html↩︎

  4. https://cran.r-project.org/web/packages/sf/vignettes/sf2.html#reading_and_writing_directly_to_and_from_spatial_databases↩︎

  5. http://wiki.openstreetmap.org/wiki/Overpass_API↩︎

  6. https://cran.r-project.org/web/packages/sf/vignettes/sf5.html#ggplot2↩︎

  7. https://cran.r-project.org/web/packages/stars/vignettes/stars3.html#geom_stars↩︎

  8. https://ggplot2-book.org/↩︎

  9. Prefixing code output with # makes the interpreter ignore it (Section 1.3.3). That way, the entire code output can be safely copied and pasted into the interpretor.↩︎

  10. “To understand computations in R, two slogans are helpful: (1) Everything that exists is an object. (2) Everything that happens is a function call.” (Chambers, 2014, Statistical Science, https://arxiv.org/pdf/1409.3531.pdf)↩︎

  11. The full list of date format symbols can be found in ?strptime↩︎

  12. When typing value < -213, make sure there is a space between < and -. Otherwise the combination is interpreted as an assignment operator <-!↩︎

  13. Note that, when comparing rates of change, which is what we inmlicitly do with which.min(d_value) and which.max(d_value), we need to divide the differences (diff(value)) by the time differences (diff(time)). In this particular dataset, this does not matter, because the time differences between measurements are fixed at ~6 months.↩︎

  14. In R versions <4.0.0, the additional stringAsFactors=FALSE argument was required to prevent the conversion of text columns to factor, which is what we usually want. A factor is a special type of a categorical vector. It is less relevant for our purposes and therefore we will not be using factor objects in this book. In R ≥4.0.0, we do not need to worry about that since stringAsFactors=FALSE became the default in functions data.frame, read.csv (Section 4.4.1) and st_read (Section 7.7).↩︎

  15. R has other functions for reading tables in other formats, such as the read.xlsx function, from the openxlsx package, for reading Excel (.xlsx) files.↩︎

  16. If there are numerous matches, the corresponding rows of x are duplicated to accomodate all matching values. This is usually an undesired situation. Therefore, we want to make sure that all values in the key column of y are unique, before doing a left join. That way, we make sure that no duplication takes place, and the join result contains exactly the same number of rows as x.↩︎

  17. Population in 2019, based on Wikipedia.↩︎

  18. Since R 4.0.0 (https://cran.r-project.org/doc/manuals/r-devel/NEWS.html).↩︎

  19. Due to the conventions of image, a matrix image is actually reversed in 90 degrees compared to the textual representation of a matrix. To get the same orientation as in the textual representation, use image(t(apply(volcano,2,rev)))↩︎

  20. There are similar functions named rowSums and colSums for calculating row and column sums, respectively.↩︎

  21. Note that there are no data structure for zero-dimensional data structures (i.e., scalars) in R.↩︎

  22. https://en.wikipedia.org/wiki/Null_Island↩︎

  23. Unless a new version of a package was released and we want to update it, in which case we need to re-install the package.↩︎

  24. GeoTIFF files can come with both *.tif and *.tiff file extension, so if one of them does not work you should try the other.↩︎

  25. Note that offset and delta should be set together, since setting one of them resets the other to NA.↩︎

  26. https://landsat.usgs.gov/what-are-band-designations-landsat-satellites↩︎

  27. This type of a false color image mapping emphasizes green vegetation (in red).↩︎

  28. We can also do the above reclassification with a single expression, using cut(ndvi, breaks = c(-Inf, 0.2, Inf)). This becomes especially convenient if we have numerous categories or classes. The result consists of values of type factor, which we don’t go into in this book.↩︎

  29. st_apply also accepts vector of (fixed) length n larger than 1, in which case st_apply returns a multi-band raster with n layers.↩︎

  30. in Windows.↩︎

  31. For a complete list of vector formats that can be read with st_read, run st_drivers(what="vector").↩︎

  32. Use valid_udunits() to see the list of available units.↩︎

  33. To avoid these “patches”, we can reduce the precision of the calculation using function st_set_precision. For example, compare the plot of st_union(st_set_precision(nm, units::set_units(1, "m"))) with the plot of st_union(nm) (Figure 8.10) (https://keen-swartz-3146c4.netlify.app/geommanip.html#precision).↩︎

  34. Alternatively, the group_by and summarize functions from package dplyr can also be used for aggregation: s2 = s %>% group_by(NAME_1) %>% summarize(area = sum(area)).↩︎

  35. For example, when the resolution of the new grid is coarser than the resolution of the original raster.↩︎

  36. The raster package does have such a function, named focal.↩︎

  37. The st_as_sf function is used to transform from stars to sf, which we learn about in Section 10.3.↩︎

  38. If necessary, we can convert those pixels that have NA in all layers to polygons, too, by specifying na.rm=FALSE.↩︎

  39. If necessary, we can convert those pixels that have NA in all layers to points, too, by specifying na.rm=FALSE.↩︎

  40. Recall that we already used aggregate for a different use case: dissolving vector layers by attribute (Section 8.4).↩︎

  41. Note that using aggregate to extract raster values by polygons is only appropriate for non-overlapping polygons. For polygons that are potentially overlapping, use raster::extract.↩︎

  42. The ~ 1 part means there are no independent variables other than the intercept.↩︎