Skip to content

Commit d8a25bc

Browse files
authored
Merge pull request #31 from Permian-Global-Research/rcmdcheck-fix
Rcmdcheck fix
2 parents 7f00f49 + 7312556 commit d8a25bc

9 files changed

+59
-37
lines changed

R/chewie-find.r

+3-1
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@
2929
#' details.
3030
#'
3131
#' @examplesIf interactive()
32+
#'
3233
#' humboldt <- sf::read_sf(
3334
#' system.file("geojson", "humboldt.geojson", package = "chewie")
3435
#' )
3536
#' humboldt_find_2a <- find_gedi(humboldt,
3637
#' gedi_product = "2A",
37-
#' date_start = "2022-01-01", date_end = "2022-04-01",
38+
#' date_start = "2022-01-01",
39+
#' date_end = "2022-04-01",
3840
#' cache = FALSE
3941
#' )
4042
#' print(humboldt_find_2a)

R/chewie-grab.r

+13-2
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,17 @@ chewie_mk_parquet <- function(
148148
)
149149
check_n_make_dir(save_dir)
150150

151+
gedi_tib <- dplyr::as_tibble(gedi_dt)
152+
153+
# Remove the .internal.selfref attribute
154+
attrs <- attributes(gedi_tib)
155+
if (".internal.selfref" %in% names(attrs)) {
156+
attrs$.internal.selfref <- NULL
157+
attributes(gedi_tib) <- attrs
158+
}
159+
151160
arrow::write_parquet(
152-
dplyr::as_tibble(gedi_dt),
161+
gedi_tib,
153162
file.path(
154163
save_dir,
155164
paste0(
@@ -266,7 +275,9 @@ download_wrap <- function(
266275

267276

268277
dd_full_split <- sf::st_drop_geometry(x2d_chunk) |>
269-
dplyr::mutate(destfile = normalizePath(.data$destfile, mustWork = FALSE)) |>
278+
dplyr::mutate(
279+
destfile = normalizePath(.data$destfile, mustWork = FALSE)
280+
) |>
270281
dplyr::select("destfile", "id") |>
271282
dplyr::right_join(df_down, by = "destfile") |>
272283
dplyr::group_split(dplyr::row_number())

README.Rmd

+5-7
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,10 @@ First, let's load in some libraries. {dplyr} isn't essential but it is
8484
recommended as it's an excellent and highly performative option for working with
8585
arrow datasets.
8686

87-
```{r load-libs}
88-
suppressPackageStartupMessages({
89-
library(chewie)
90-
library(dplyr)
91-
library(sf)
92-
})
87+
```{r load-libs, message = FALSE}
88+
library(chewie)
89+
library(dplyr)
90+
library(sf)
9391
```
9492

9593
Here are some useful helper functions to set up your credentials (using
@@ -116,7 +114,7 @@ prairie_creek <- sf::read_sf(system.file(
116114
package = "chewie"
117115
))
118116
119-
gedi_2a_search <- x <- find_gedi(prairie_creek,
117+
gedi_2a_search <- find_gedi(prairie_creek,
120118
gedi_product = "2A",
121119
date_start = "2023-01-01",
122120
date_end = "2023-01-31"

README.md

+4-6
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,9 @@ recommended as it’s an excellent and highly performative option for
5353
working with arrow datasets.
5454

5555
``` r
56-
suppressPackageStartupMessages({
57-
library(chewie)
58-
library(dplyr)
59-
library(sf)
60-
})
56+
library(chewie)
57+
library(dplyr)
58+
library(sf)
6159
```
6260

6361
Here are some useful helper functions to set up your credentials (using
@@ -85,7 +83,7 @@ prairie_creek <- sf::read_sf(system.file(
8583
package = "chewie"
8684
))
8785

88-
gedi_2a_search <- x <- find_gedi(prairie_creek,
86+
gedi_2a_search <- find_gedi(prairie_creek,
8987
gedi_product = "2A",
9088
date_start = "2023-01-01",
9189
date_end = "2023-01-31"

_pkgdown.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
url: https://permian-global-research.github.io/chewie/
22
template:
33
bootstrap: 5
4-
bootswatch: minty
4+
light-switch: true
5+
theme: gruvbox-light
6+
theme-dark: gruvbox-dark
7+
58
reference:
69
- title: Credentials Management
710
contents:

data-raw/chewie-test-cache.R

+7-4
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,20 @@ if (!file.exists(".Renviron")) {
44
file.create(".Renviron")
55
}
66

7+
library(devtools)
8+
devtools::load_all()
9+
10+
chewie_setup_cache("data-raw/chewie-test-cache", renviron = "project")
11+
chewie_health_check()
12+
713
# chewie::chewie_clear_h5_temp_cache()
814
# chewie::chewie_clear_find_cache()
915
# chewie::chewie_clear_parquet_cache("2B")
1016
# chewie::chewie_clear_parquet_cache("2A")
1117
# chewie::chewie_clear_parquet_cache("1B")
1218
# chewie::chewie_clear_parquet_cache("4A")
1319

14-
library(devtools)
15-
devtools::load_all()
1620

17-
chewie_setup_cache("data-raw/chewie-test-cache", renviron = "project")
18-
chewie_health_check()
1921
# chewie_clear_find_cache()
2022

2123
# --- Download test GEDI data -------------------------------------------------
@@ -100,6 +102,7 @@ clip_n_save_parquet <- function(x) {
100102

101103
chewie:::check_n_make_dir(save_dir)
102104

105+
103106
arrow::write_parquet(
104107
dplyr::as_tibble(xc),
105108
file.path(

inst/chewie-test-cache.zip

-15.6 KB
Binary file not shown.

man/chewie-find-gedi.Rd

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vignettes/gedi-L1B-waveforms.Rmd

+20-15
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ knitr::opts_chunk$set(
1212
collapse = TRUE,
1313
comment = "#>"
1414
)
15-
15+
options(arrow.unsafe_metadata = TRUE)
1616
options("chewie.testing" = TRUE)
1717
temp_dir <- tempdir()
1818
@@ -39,13 +39,11 @@ extract GEDI Level 1B waveforms.
3939

4040
First let's load the `chewie` package and the `ggplot2` package for plotting.
4141

42-
```{r setup}
43-
suppressPackageStartupMessages({
44-
library(chewie)
45-
library(ggplot2)
46-
library(sf)
47-
library(dplyr)
48-
})
42+
```{r setup, message = FALSE}
43+
library(chewie)
44+
library(ggplot2)
45+
library(sf)
46+
library(dplyr)
4947
```
5048

5149
First, we define an area of interest. In this case, we will use prairie creek
@@ -67,7 +65,7 @@ Now we can search for GEDI Level 1B products that intersect with our area of
6765
interest. We will search for products that were collected between January 1st
6866
and January 31st, 2023.
6967

70-
```{r find-gedi}
68+
```{r find-gedi, warning = FALSE}
7169
g1b_search <- find_gedi(pcreek,
7270
gedi_product = "1B",
7371
date_start = "2023-01-01",
@@ -79,14 +77,17 @@ You'll see that only one granule was found. The returned `gedi.find` object
7977
contains information about the search, including whether or not the files are
8078
cached locally.
8179

80+
*Note: this vignette uses a cached granule which has been subset to include only
81+
3 beams to minimise the size of the package. The full granule contains 8 beams.*
82+
8283
Now we can download the GEDI Level 1B products. However, note that the `grab_gedi()`
8384
function will not download the products if they are already cached locally. It
8485
first checks the cache and grabs the relevant files if they exist. If they do
8586
not exist, they'll be downloaded from the LPCLOUD bucket. {chewie} will, by
8687
default only download specific data columns. There are many variables contained
8788
in the raw hdf5 files.
8889

89-
```{r grab-gedi}
90+
```{r grab-gedi, warning = FALSE}
9091
gedi_1b_arrow <- grab_gedi(g1b_search)
9192
```
9293

@@ -98,13 +99,17 @@ In order to access the data we must first collect the data into a data frame.
9899
This could be done using `dplyr::collect`. However, the `collect_gedi()` function
99100
is a wrapper around `dplyr::collect` that also converts the data to an `sf`
100101
object, immediately providing a spatial context for the data.
101-
```{r plot-gedi}
102+
```{r plot-gedi, warning = FALSE}
102103
g1b_sf <- collect_gedi(gedi_1b_arrow, g1b_search)
103104
104105
print(g1b_sf)
105106
106-
plot(g1b_sf[0], axes = TRUE)
107-
plot(attributes(g1b_search)$aoi, add = TRUE, border = "#7700ff")
107+
ggplot() +
108+
geom_sf(data = attributes(g1b_search)$aoi, fill = "#1bbe8086") +
109+
geom_sf(data = g1b_sf, aes(colour = elevation_lastbin)) +
110+
guides(colour = "none") +
111+
scale_color_viridis_c(option = "A") +
112+
theme_light()
108113
```
109114

110115
So, here's the cool bit about the way the Level-1B data are extracted. We can
@@ -123,7 +128,7 @@ print(g1b_wvf)
123128

124129
And plot them using `ggplot2`...
125130

126-
```{r plot-waveforms}
131+
```{r plot-waveforms }
127132
wvf_ggplot <- function(x, wf, z, .ylab = "Elevation (m)") {
128133
wf <- sym(wf)
129134
z <- sym(z)
@@ -159,7 +164,7 @@ g1b_wvf |>
159164
scale_x_reverse()
160165
```
161166

162-
```{r cleanup}
167+
```{r cleanup, include=FALSE}
163168
if (file.exists(".Renviron")) {
164169
file.remove(".Renviron")
165170
}

0 commit comments

Comments
 (0)