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

add development section #11

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions R/read_smips.R
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ read_smips <- function(collection = "totalbucket",

if (.collection == "totalbucket" &&
.url_year < 2005 ||
# NOTE: this is throwing "'tzone' attributes are inconsistent"
.day > .last_week) {
cli::cli_abort("The data are not available before 2005 and roughly
much past { .last_week }")
Expand Down
34 changes: 31 additions & 3 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ knitr::opts_chunk$set(

<!-- badges: start -->
[![R-CMD-check](https://github.com/AAGI-AUS/nert/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/AAGI-AUS/nert/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/AAGI-AUS/nert/graph/badge.svg)](https://app.codecov.io/gh/AAGI-AUS/nert)
[![codecov](https://codecov.io/gh/AAGI-AUS/nert/graph/badge.svg?token=WgBeTrqQnQ)](https://codecov.io/gh/AAGI-AUS/nert)
<!-- badges: end -->

The goal of {nert} is to provide access to Australian TERN (Terrestrial Ecosystem Research Network) data in your R session.
Expand All @@ -38,18 +38,20 @@ pak::pak("AAGI-AUS/nert")

This is a basic example which shows you how you can fetch one day's data from the SMIPS data (currently the only supported data set in TERN) and visualise it:

```{r example_cog}
```{r example_cog, eval=FALSE}
library(nert)
r <- read_smips(day = "2024-01-01")

plot(r)
```

![example plot](./man/figures/README-example_cog-1.png)

## Extract Values Given Lat/Lon Values

Extract Soil Moisture for Corrigin and Merriden, WA and Tamworth, NSW given latitude and longitude values for each.

```{r}
```{r, eval=FALSE}
library(terra)
df <- structure(
list(
Expand All @@ -66,4 +68,30 @@ cog_df <- extract(x = r, y = df[, c("x", "y")], xy = TRUE)
cog_df <- cbind(df$location, cog_df)
names(cog_df) <- c("location", "ID", "smips_totalbucket_mm_20240101", "x", "y")
cog_df
#> location ID smips_totalbucket_mm_20240101 x y
#> 1 Corrigin 1 0.06715473 117.8688 -32.33328
#> 2 Merredin 2 0.22716530 118.2787 -31.48353
#> 3 Tamworth 3 93.44989014 150.8408 -31.07365
```

## Development

### Dev Container

Set up the container.

```{bash, eval=FALSE}
devcontainer up --workspace-folder .
```

Run tests and check stuff.

```{bash, eval=FALSE}
devcontainer exec --workspace-folder . R -e "devtools::check()"
```

Render this file.

```{bash, eval=FALSE}
devcontainer exec --workspace-folder . R -e "devtools::build_readme()"
```
39 changes: 27 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
<!-- badges: start -->

[![R-CMD-check](https://github.com/AAGI-AUS/nert/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/AAGI-AUS/nert/actions/workflows/R-CMD-check.yaml)
[![Codecov test
coverage](https://codecov.io/gh/AAGI-AUS/nert/graph/badge.svg)](https://app.codecov.io/gh/AAGI-AUS/nert)
[![codecov](https://codecov.io/gh/AAGI-AUS/nert/graph/badge.svg?token=WgBeTrqQnQ)](https://codecov.io/gh/AAGI-AUS/nert)
<!-- badges: end -->

The goal of {nert} is to provide access to Australian TERN (Terrestrial
Expand All @@ -34,20 +33,15 @@ visualise it:

``` r
library(nert)
#>
#> Attaching package: 'nert'
#> The following object is masked from 'package:graphics':
#>
#> plot
#> The following object is masked from 'package:base':
#>
#> plot
r <- read_smips(day = "2024-01-01")

plot(r)
```

<img src="man/figures/README-example_cog-1.png" width="100%" />
<figure>
<img src="./man/figures/README-example_cog-1.png" alt="example plot" />
<figcaption aria-hidden="true">example plot</figcaption>
</figure>

## Extract Values Given Lat/Lon Values

Expand All @@ -56,7 +50,6 @@ given latitude and longitude values for each.

``` r
library(terra)
#> terra 1.7.83
df <- structure(
list(
location = c("Corrigin", "Merredin", "Tamworth"),
Expand All @@ -77,3 +70,25 @@ cog_df
#> 2 Merredin 2 0.22716530 118.2787 -31.48353
#> 3 Tamworth 3 93.44989014 150.8408 -31.07365
```

## Development

### Dev Container

Set up the container.

``` bash
devcontainer up --workspace-folder .
```

Run tests and check stuff.

``` bash
devcontainer exec --workspace-folder . R -e "devtools::check()"
```

Render this file.

``` bash
devcontainer exec --workspace-folder . R -e "devtools::build_readme()"
```
Binary file modified man/figures/README-example_cog-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.