Giter VIP home page Giter VIP logo

sdsr's Introduction

The print version of this book is available from CRC/Chapman and Hall. A complete online version of this book is available.

To recreate/reproduce this book:

  • git clone this repository
  • download the data used in Ch 13, and extract the contents of the aq subdirectory into sdsr/aq
  • install R package dependencies listed below
  • install quarto
  • run quarto render --to html

See also the Dockerfile; building the (18 Gb) image with

docker build . -t sdsr

and running it with

docker run -p 8787:8787 -e DISABLE_AUTH=true -ti --rm sdsr

will serve an Rstudio server instance on http://localhost:8787/, without authentication.

Compiling the whole book

After running the docker image and opening rstudio in the browser:

  • click on 01-hello.qmd in the bottom-right pane
  • click on the Render button of the top-left pane to compile the whole book

this should open a new browser window with the full book rendered (you may need to switch off popup blockers for localhost)

Running selected chunks

To run a selected code section, possibly after modification, find the selected code section in the corresponding .qmd file, and click the small green arrow symbols on the top-right corner of the code blocks:

  • to prepare, first click Run All Chunks Above,
  • to run a selected code chunk: click Run Current Chunk

Dependencies

To locally process the book, download (clone) this repository and install the following R packages from CRAN:

install.packages(c(
  "dbscan",
  "gstat",
  "hglm",
  "igraph",
  "lme4",
  "lmtest",
  "maps",
  "mapview",
  "matrixStats",
  "mgcv",
  "R2BayesX",
  "rgeoda",
  "rnaturalearth",
  "rnaturalearthdata",
  "sf",
  "spatialreg",
  "spdep",
  "spData",
  "stars",
  "tidyverse",
  "viridis",
  "tmap"))

Install INLA:

install.packages("INLA", repos = c(getOption("repos"), INLA="https://inla.r-inla-download.org/R/stable"))

Install spDataLarge:

options(timeout = 600); install.packages("spDataLarge", repos = "https://nowosad.github.io/drat/",type = "source")

Install starsdata:

options(timeout = 1200); install.packages("starsdata", repos = "http://cran.uni-muenster.de/pebesma", type = "source")

Install spatialreg from source from github, either from source:

install.packages("remotes")
remotes::install_github("r-spatial/spatialreg")

or as binary from r-universe:

options(repos = c(
  rspatial = "https://r-spatial.r-universe.dev",
  CRAN = "https://cloud.r-project.org"))
install.packages(c("spatialreg"))

Daily rendered version on GA

The entire book is recreated from source nightly with the latest released R and all updated CRAN packages by a Github Action using this script. The online version thus rendered is found here. As this output is not checked daily it is not automatically copied to the "official" online version, at https://r-spatial.org/book/ .

Python version

A version "With Applications in R and Python" is under construction; the sources are in the python branch of this repository, a rendered online version is found at https://r-spatial.org/python/ .

sdsr's People

Contributors

alanguillaume avatar andronaco avatar angela-li avatar edzer avatar florisvdh avatar h-ndre avatar hansvancalster avatar hurielreichel avatar ismailsunni avatar jafro96 avatar jonas-hurst avatar jonathom avatar kadyb avatar liuyadong avatar mikemahoney218 avatar nowosad avatar ppaccioretti avatar robinlovelace avatar rsbivand avatar singhkpratham avatar smkerr avatar suriyahgit avatar syverpet avatar vasilygrz avatar wibeasley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sdsr's Issues

Github Actions

now running, still todo:

  • render python branch somewhere else (netlify?)
  • run on PRs
  • Python branch in cron job
  • add to README that this is a daily built, unchecked
  • install spatialreg from CRAN, once released
  • put errata somewhere, with link

where are the rendered pull requests?

How should I update/re-generate the netlify rendering after edits locally? Through PRs, the main site (_book?) will not update until you change/merge, right? I shouldn't mess with _book, I think, because then PRs will pick up my changes ...

Maybe define "affine"?

I think it appease in section 6.2.1 and is never really defined. But it might be obvious to this audience, and not need defining.

"With two affine parameters..."

(Don't tell anyone, but I might have had to peek at the definition to remind myself.)

Tiny typo in Point Pattern Analysis

In the following bullet point in the first section of Ch 11 there's a small typo, I guess it should be "they".

second order properties, e.g. pairwise interactions: given a constant or varying intensity function, are points distributed independently from one another, or do the tend to attract each other (clustering) or repulse each other (appear regularly distributed, compared to independence)

stuck at 5090-5092 (sds.Rmd)

I have the vector PostgreSQL driver but not PostGIS. I do not want to install PostGIS (because it depends on GDAL/GEOS/PROJ which I install from source and change frequently). The has_PG test doesn't check that the driver works. How to skip these sections?

Add content about containers

Have you considered adding a short chapter, on the same level as "R data structures" chapter?

I think the installation of geospatial packages has made a huge leap forward, but there still might be times or reasons where readers of the book would profit from a quick introduction in the the `rocker/geospatial´ images.

This section could also extend a bit on the idea of reproducibility, which so far is only mentioned in the preface.

Do you have a plan to publish?

I studied a few pieces of puzzle of 'Spatial data science' from here and there

( It's always not enough for me. )

and found your draft by accident.

It is to me something like '101 stuff for practical spatial data science'

I really enjoyed reading your draft.

Thank you for sharing such a great work!

Do you have any plan to publish the book? (when?)

I am eager to know it and buy one.

paragraph 13.1, is there a possible typo?

Hello,
I'm here just wondering the why of:

r <- lapply(files[-1], function(f) read.csv(f))

in particular I'm referring to the subsetting files[-1];

if I understand well the purpose (reading all files), shouldn't be something like this:

r <- lapply(files, function(f) read.csv(f))

or do I miss something?

Thank you so much for your excellent work.

Best

Ch 9, 9.3

Should we mention for example gridGraphics:: grid.echo () and grid::grid.grab() ? Should we point to geocompr section 8.2.7 on viewports and inset maps? Could tmap be mentioned in 9 in the grid part? Or point to geocompr and tmaps JSS article?

Split ch 17?

My ch 17 is now 35K, and could happily be two shorter chapters, 17 Spatial weights, 17a Spatial autocorrelation, followed by 18 Spatial regression. How do I do that? Bump 18, 19, 20 with git mv?

build output

How can I build the output of one or more chapters? Run make book? That builds everything, doesn't it? Can I build out-of-repo so that I avoid generating a PR including the built book? It is hard to write without control over the output.

Ch 16 a bit unpolished

Ch 16 is a bit unpolished; some figures deserve more explanation, some missing punctuation, etc. But OK to send to reviewers. I see that Ch 17-18 have a higher reference density, maybe that doesn't matter.

Commas for empty raster dimension

Something with the double commas was not interpreted correctly by the copy editing process for the hardcover. Instead of successive commas, it looks like a uncurly/straight double quote mark (that is also lowered like a subscript).

This means that `r[1:2, 101:200,, 5:10]`

17038093007943383835277776366933

new error in Ch 16

We see a new error in this action

Quitting from lines 180-184 [unnamed-chunk-12] (16-SpatialRegression.qmd)
1080 Error in `initializePtr()`:
1081 ! function 'cholmod_factor_ldetA' not provided by package 'Matrix'
1082 Backtrace:
1083   1. lme4::lmer(...)
1084   3. lme4 (local) `<fn>`(...)
1085   5. methods (local) `<rfMthdDf>`(...)
1086   6. methods::new(def, ...)
1087   8. methods::initialize(value, ...)
1088   9. .Object$initialize(...)
1089  10. lme4 (local) initializePtr()

@rsbivand is this something you could look at?

plot error in 7.4.2 Example: Bristol origin-destination datacube

Hi, there is an error with the last line here. Not sure what the correct code should be.

In this section: 7.4.2 Example: Bristol origin-destination datacube

library(units)
a = set_units(st_area(st_as_sf(o)), km^2)
o$sum_km = o$sum / a
d$sum_km = d$sum / a
od = c(o["sum_km"], d["sum_km"], along = list(od = c("origin", "destination")))
plot(od, logz = TRUE)

Error in Ops.units(at, br[1]) : both operands of the expression should be "units" objects

> sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.6 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

locale:
 [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8        LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8   
 [6] LC_MESSAGES=C.UTF-8    LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C           LC_TELEPHONE=C        
[11] LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] units_0.7-2       spDataLarge_2.0.6 xts_0.12.1        zoo_1.8-8         spacetime_1.2-8   stars_0.5-2       abind_1.4-5      
 [8] forcats_0.5.0     stringr_1.4.0     dplyr_1.0.8       purrr_0.3.4       readr_2.0.2       tidyr_1.2.0       tibble_3.1.6     
[15] ggplot2_3.3.5     tidyverse_1.3.0   sf_1.0-8         

loaded via a namespace (and not attached):
 [1] httr_1.4.2         jsonlite_1.7.2     modelr_0.1.8       assertthat_0.2.1   sp_1.4-5           cellranger_1.1.0   yaml_2.2.1        
 [8] pillar_1.6.4       backports_1.2.1    lattice_0.20-41    glue_1.6.2         digest_0.6.27      rvest_1.0.1        colorspace_2.0-2  
[15] htmltools_0.5.2    pkgconfig_2.0.3    broom_0.8.0        haven_2.3.1        s2_1.1.0           intervals_0.15.2   scales_1.2.0      
[22] tzdb_0.1.2         proxy_0.4-26       generics_0.1.2     ellipsis_0.3.2     withr_2.5.0        cli_3.3.0          magrittr_2.0.1    
[29] crayon_1.4.2       readxl_1.3.1       evaluate_0.14      fs_1.5.0           fansi_0.5.0        MASS_7.3-53        xml2_1.3.2        
[36] lwgeom_0.2-5       class_7.3-17       tools_4.0.3        hms_0.5.3          lifecycle_1.0.1    munsell_0.5.0      reprex_0.3.0      
[43] packrat_0.7.0      compiler_4.0.3     e1071_1.7-9        rlang_1.0.2        classInt_0.4-3     grid_4.0.3         rstudioapi_0.13   
[50] cubelyr_1.0.1      rmarkdown_2.11     wk_0.6.0           gtable_0.3.0       DBI_1.1.1          R6_2.5.1           lubridate_1.7.10  
[57] knitr_1.34         fastmap_1.1.0      utf8_1.2.2         KernSmooth_2.23-17 stringi_1.7.4      parallel_4.0.3     Rcpp_1.0.7        
[64] vctrs_0.3.8        dbplyr_2.1.1       tidyselect_1.1.2   xfun_0.25  

Some additional comments to chapters 8 and 9

Chapter 8:

  • Gb or GB? Tb or TB? You use Gb and Tb, but (correct me if I am wrong) I think it should be GB and TB
  • " In such cases it may be most helpful to either gain access to (typically: rent) virtual machines in a cloud where these data are available and nearby" - there is something wrong with this sentence...

Chapter 9:

  • You use "color" in some sentences and "colour" in others...
  • "Good colors scales are e.g. found in packages RColorBrewer [@R-RColorBrewer], viridis [@R-viridis] or colorspace [@R-colorspace; @colorspace]." - maybe it is worth to mention the hcl.colors and palette.colors functions as they have all of the palettes methioned before...
  • A few figure captions are not completed, for example "fig captions tmap: using ..."
  • @ref(fig:mapviewfigure) is broken

Formatting questions and suggestions

Hi @edzer,

I'm learning spatial statistics and I'd like to, first of all, thank you and @rsbivand for publishing this open access book. Currently, I've read more than half of it and I'd to ask the following questions:

  1. What style guide are you following?
  2. Why function arguments within the text end in =? For example, 'Durbin= argument' from Ch. 17.
    Would removing them create unnecessary confusion?

Regarding the style guide, I've noticed that dashes aren't used in the text. Following the New Hart's Rules: The Oxford Style Guide (2014), which I use as a reference, we can choose between en (&ndash;) or em (&mdash;) dashes.

4.11.1 En rule (p. 86)
The en rule (US en dash) (–) is longer than a hyphen and half the length of an em rule (—). Many British publishers use an en rule with space either side as a parenthetical dash, but Oxford and most US publishers use an em rule.

If we chose the en rule, this is how it would look like (Examples from Ch. 1):

  • 'Figure 1.1: A first map: birth counts 1974–78, North Carolina counties' [1]
  • 'When we have longer time series associated with geometries, neither option – distributing time over multiple columns, or stacking columns while repeating geometries – works well, and a more effective way of storing such data would be a matrix or array, where one dimension refers to time, and the other(s) to space.' [2]

Similarly, there are a few typos regarding linking chapters. Instead of [3]

is shown in @fig-tmapstars. More examples of the use of tmap are given in Chapters -@sec-area - -@sec-spatglmm.

it should be

is shown in @fig-tmapstars. More examples of the use of tmap are given in @sec-area–@sec-spatglmm.

It also happens in 10.2 Support and statistical modelling.

I can correct this punctuation issue if you want me to.

Ch 10 affordances

I had to look up affordances, and suggest properties instead (line 31).

Misspelling in Preface

Edzer,

I am not up to speed on git to fix this myself, but as you asked for comments on twitter, there is a misspelling in the Preface:

"coordinate pairs really are pairs, and loose much of their meaning when treated separately"

"loose" should be "lose"

How to get the air quality dataset in Chapter 16 Interpolation and Geostatistics

Hello @edzer. I'm reading your book Spatial Data Science. It's awesome! I like doing spatial analysis in the sf way~

I have a little question In chapter 16, although the URL of air quality data is provided, and it is said:

It returns a text file with a set of URLs to CSV files, each containing the hourly values for the whole period for a single measurement station. These files were downloaded and converted to the right encoding using the dos2unix command line utility.

I'm still confused about how to get the data in the right place so that I can follow this chapter. Could you please provide more details?

Many thanks for your kind guidance!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.