Skip to content

Commit e35b0c7

Browse files
authored
Merge branch 'main' into patch-2
2 parents 9d4afb4 + c93e271 commit e35b0c7

File tree

7 files changed

+124
-122
lines changed

7 files changed

+124
-122
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ __pycache__
5858
vendor/
5959
.docker-vendor/
6060
Gemfile.lock
61-
.*history
61+
.*history

episodes/01-raster-structure.Rmd

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,16 +318,14 @@ raster: surface elevation in meters for one time period.
318318

319319
A raster dataset can contain one or more bands. We can use the `rast()`
320320
function to import one single band from a single or multi-band raster. We can
321-
view the number of bands in a raster using the `nly()` function.
321+
view the number of bands in a raster using the `nlyr()` function.
322322

323323
```{r view-raster-bands}
324324
nlyr(DSM_HARV)
325325
```
326326

327-
However, raster data can also be multi-band, meaning that one raster file
328-
contains data for more than one variable or time period for each cell.
329-
Jump to a later episode in
330-
this series for information on working with multi-band rasters:
327+
However, raster data can also be multi-band, meaning that one raster file contains data for more than one variable or time period for each cell.
328+
Jump to a later episode in this series for information on working with multi-band rasters:
331329
[Work with Multi-band Rasters in R](05-raster-multi-band-in-r/).
332330

333331
## Dealing with Missing Data

episodes/02-raster-plot.Rmd

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,11 @@ values of `fct_elevation`:
8585
unique(DSM_HARV_df$fct_elevation)
8686
```
8787

88-
And we can get the count of values in each group using `dplyr`'s `group_by()`
89-
and `count()` functions:
88+
And we can get the count of values in each group using `dplyr`'s `count()` function:
9089

9190
```{r breaks-count}
9291
DSM_HARV_df %>%
93-
group_by(fct_elevation) %>%
94-
count()
92+
count(fct_elevation)
9593
```
9694

9795
We might prefer to customize the cutoff values for these groups.
@@ -133,8 +131,7 @@ And we can get the count of values in each group in the same way we did before:
133131

134132
```{r break-count-custom}
135133
DSM_HARV_df %>%
136-
group_by(fct_elevation_2) %>%
137-
count()
134+
count(fct_elevation_2)
138135
```
139136

140137
We can use those groups to plot our raster data, with each group being a

episodes/05-raster-multi-band-in-r.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Each RGB image is a 3-band raster. The same steps would apply to working with a
5555
multi-spectral image with 4 or more bands - like Landsat imagery.
5656

5757
By using the `rast()` function along with the `lyrs` parameter, we can read
58-
specific raster bands (i.e. the first one); omitting this parater would read
58+
specific raster bands (i.e. the first one); omitting this parameter would read
5959
instead all bands.
6060

6161
```{r read-single-band}

episodes/setup.R

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,43 @@ options(timeout = max(300, getOption('timeout')))
22
## file structure
33

44
if (! file.exists("data/NEON-DS-Site-Layout-Files")) {
5-
dest <- tempfile()
6-
download.file("https://ndownloader.figshare.com/files/3708751", dest,
7-
mode = "wb")
8-
unzip(dest, exdir = "data")
5+
dest <- tempfile()
6+
download.file("https://ndownloader.figshare.com/files/3708751", dest,
7+
mode = "wb")
8+
unzip(dest, exdir = "data")
99
}
1010

1111
if (! file.exists("data/NEON-DS-Airborne-Remote-Sensing")) {
12-
dest <- tempfile()
13-
download.file("https://ndownloader.figshare.com/files/3701578", dest,
14-
mode = "wb")
15-
unzip(dest, exdir = "data")
12+
dest <- tempfile()
13+
download.file("https://ndownloader.figshare.com/files/3701578", dest,
14+
mode = "wb")
15+
unzip(dest, exdir = "data")
1616
}
1717

1818
if (! file.exists("data/NEON-DS-Met-Time-Series")) {
19-
dest <- tempfile()
20-
download.file("https://ndownloader.figshare.com/files/3701572", dest,
21-
mode = "wb")
22-
unzip(dest, exdir = "data")
19+
dest <- tempfile()
20+
download.file("https://ndownloader.figshare.com/files/3701572", dest,
21+
mode = "wb")
22+
unzip(dest, exdir = "data")
2323
}
2424

2525
if (! file.exists("data/NEON-DS-Landsat-NDVI")) {
26-
dest <- tempfile()
27-
download.file("https://ndownloader.figshare.com/files/4933582", dest,
28-
mode = "wb")
29-
unzip(dest, exdir = "data")
26+
dest <- tempfile()
27+
download.file("https://ndownloader.figshare.com/files/4933582", dest,
28+
mode = "wb")
29+
unzip(dest, exdir = "data")
3030
}
3131

3232
if (! file.exists("data/Global/Boundaries/ne_110m_graticules_all")) {
33-
dest <- tempfile()
34-
download.file("https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/physical/ne_110m_graticules_all.zip",
35-
dest, mode = "wb")
36-
unzip(dest, exdir = "data/Global/Boundaries/ne_110m_graticules_all")
33+
dest <- tempfile()
34+
download.file("https://naciscdn.org/naturalearth/110m/physical/ne_110m_graticules_all.zip",
35+
dest, mode = "wb")
36+
unzip(dest, exdir = "data/Global/Boundaries/ne_110m_graticules_all")
3737
}
3838

3939
if (! file.exists("data/Global/Boundaries/ne_110m_land")) {
40-
dest <- tempfile()
41-
download.file("https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/physical/ne_110m_land.zip",
42-
dest, mode = "wb")
43-
unzip(dest, exdir = "data/Global/Boundaries/ne_110m_land")
40+
dest <- tempfile()
41+
download.file("https://naciscdn.org/naturalearth/110m/physical/ne_110m_land.zip",
42+
dest, mode = "wb")
43+
unzip(dest, exdir = "data/Global/Boundaries/ne_110m_land")
4444
}

renv/activate.R

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
local({
33

44
# the requested version of renv
5-
version <- "1.0.5"
5+
version <- "1.0.7"
66
attr(version, "sha") <- NULL
77

88
# the project directory
9-
project <- getwd()
9+
project <- Sys.getenv("RENV_PROJECT")
10+
if (!nzchar(project))
11+
project <- getwd()
1012

1113
# use start-up diagnostics if enabled
1214
diagnostics <- Sys.getenv("RENV_STARTUP_DIAGNOSTICS", unset = "FALSE")
@@ -129,6 +131,21 @@ local({
129131

130132
}
131133

134+
heredoc <- function(text, leave = 0) {
135+
136+
# remove leading, trailing whitespace
137+
trimmed <- gsub("^\\s*\\n|\\n\\s*$", "", text)
138+
139+
# split into lines
140+
lines <- strsplit(trimmed, "\n", fixed = TRUE)[[1L]]
141+
142+
# compute common indent
143+
indent <- regexpr("[^[:space:]]", lines)
144+
common <- min(setdiff(indent, -1L)) - leave
145+
paste(substring(lines, common), collapse = "\n")
146+
147+
}
148+
132149
startswith <- function(string, prefix) {
133150
substring(string, 1, nchar(prefix)) == prefix
134151
}
@@ -631,6 +648,9 @@ local({
631648

632649
# if the user has requested an automatic prefix, generate it
633650
auto <- Sys.getenv("RENV_PATHS_PREFIX_AUTO", unset = NA)
651+
if (is.na(auto) && getRversion() >= "4.4.0")
652+
auto <- "TRUE"
653+
634654
if (auto %in% c("TRUE", "True", "true", "1"))
635655
return(renv_bootstrap_platform_prefix_auto())
636656

@@ -822,24 +842,23 @@ local({
822842

823843
# the loaded version of renv doesn't match the requested version;
824844
# give the user instructions on how to proceed
825-
remote <- if (!is.null(description[["RemoteSha"]])) {
845+
dev <- identical(description[["RemoteType"]], "github")
846+
remote <- if (dev)
826847
paste("rstudio/renv", description[["RemoteSha"]], sep = "@")
827-
} else {
848+
else
828849
paste("renv", description[["Version"]], sep = "@")
829-
}
830850

831851
# display both loaded version + sha if available
832852
friendly <- renv_bootstrap_version_friendly(
833853
version = description[["Version"]],
834-
sha = description[["RemoteSha"]]
854+
sha = if (dev) description[["RemoteSha"]]
835855
)
836856

837-
fmt <- paste(
838-
"renv %1$s was loaded from project library, but this project is configured to use renv %2$s.",
839-
"- Use `renv::record(\"%3$s\")` to record renv %1$s in the lockfile.",
840-
"- Use `renv::restore(packages = \"renv\")` to install renv %2$s into the project library.",
841-
sep = "\n"
842-
)
857+
fmt <- heredoc("
858+
renv %1$s was loaded from project library, but this project is configured to use renv %2$s.
859+
- Use `renv::record(\"%3$s\")` to record renv %1$s in the lockfile.
860+
- Use `renv::restore(packages = \"renv\")` to install renv %2$s into the project library.
861+
")
843862
catf(fmt, friendly, renv_bootstrap_version_friendly(version), remote)
844863

845864
FALSE

0 commit comments

Comments
 (0)