Skip to content

Commit

Permalink
Merge pull request #189 from inbo/dev_nextrelease
Browse files Browse the repository at this point in the history
Preparing version 0.11.0
  • Loading branch information
florisvdh authored Oct 3, 2024
2 parents 2c2af9b + 73a0a91 commit 74bce51
Show file tree
Hide file tree
Showing 35 changed files with 2,649 additions and 683 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/R-CMD-check-latest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: false

- name: Add ubuntugis-unstable PPA (Linux)
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@ jobs:
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/site-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/site-devel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

Expand All @@ -31,7 +31,7 @@ jobs:
Rscript -e 'options(rmarkdown.html_vignette.check_title = FALSE); pkgdown::build_site()'
- name: Upload pkgdown-site as artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: pkgdown-site
path: docs
2 changes: 1 addition & 1 deletion .zenodo.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "GPL-3.0",
"upload_type": "software",
"access_right": "open",
"version": "0.10.1",
"version": "0.11.0",
"creators": [
{
"name": "Vanderhaeghe, Floris",
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: n2khab
Title: Providing Preprocessed Reference Data for Flemish Natura 2000 Habitat Analyses
Version: 0.10.1
Version: 0.11.0
Authors@R: c(
person("Floris", "Vanderhaeghe", email = "floris.vanderhaeghe@inbo.be", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-6378-6229")),
person("Toon", "Westra", email = "toon.westra@inbo.be", role = c("aut"), comment = c(ORCID = "0000-0003-2478-9459")),
Expand Down Expand Up @@ -46,7 +46,7 @@ Imports:
tidyr (>= 1.0.0),
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.2.3
RoxygenNote: 7.3.2
Suggests:
bib2df,
digest,
Expand Down
31 changes: 31 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
# n2khab 0.11.0 (2024-10-03)

## Support for new data source versions

The following new data source versions are now supported by the corresponding functions (#184):

- `habitatmap_2023` (`read_habitatmap()`)
- `habitatmap_stdized_2023_v1` (`read_habitatmap_stdized()`)
- `habitatmap_terr_2023_v1` (`read_habitatmap_terr()`)
- `habitatstreams_2023` (`read_habitatstreams()`)
- `watersurfaces_hab_v5` (`read_watersurfaces_hab()`)

Function documentation was updated accordingly.

## Drop `rbbvos+` from built-in data sources

- Type `rbbvos+` has been considered too loosely defined, as an intermediate between `rbbvos` and `6510_hua`, and it has not been mapped consistently.
Hence this type is considered obsolete and it has been dropped from the `types` and `namelist` data sources (#182).
However do note that it exists in versions of `habitatmap` and derived data sources.
- `expand_types()` has been adjusted accordingly (#182).

## Other updates

Including:

- the `fix_geom` implementation in `read_watersurfaces()` is now more efficient (#185);
- `read_habitatmap()` also gained a `fix_geom` argument (#184);
- `read_habitatsprings()` now returns integer IDs as integers (#180);
- `expand_types()` with a grouped data frame is now more efficient ([13d05ec](https://github.com/inbo/n2khab/commit/13d05ec));
- several fixes (#186, [88f0e19](https://github.com/inbo/n2khab/commit/88f0e19)).

# n2khab 0.10.1 (2023-12-04)

- Silently ignore errors from package {remotes} during package loading ([56e9c06](https://github.com/inbo/n2khab/commit/56e9c06)).
Expand Down
50 changes: 28 additions & 22 deletions R/datawrangling.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@
#' \item{for 2330: both subtype codes must be present}
#' \item{for 5130: 5130_hei must be present (note that only the main type code
#' occurs in the targeted data sources)}
#' \item{for 6230: 6230_ha, 6230_hmo and 6230_hnk must be present
#' \item{for 6230: 6230_ha, 6230_hmo and 6230_hn must be present
#' (not the rare 6230_hnk)}
#' \item{for 91E0: 91E0_va, 91E0_vm and 91E0_vn must be present
#' (not the rarer 91E0_sf, 91E0_vc and 91E0_vo)}
#' }
#' However, it is possible to relax this requirement by setting
#' \code{strict = FALSE}.
#' This will add the main type code whenever \emph{one} corresponding subtype
#' code is present.
#' This will add the main type code whenever \emph{one} of the above required
#' subtype codes is present.
#' In all cases no other main type codes are added apart from
#' 2330, 5130, 6230 and 91E0.
#' This is because the data sources with which the result
#' is to be matched (see Description) don't contain certain main type codes,
#' and because it makes no sense in other cases
#' (rbbkam, rbbvos, rbbzil & 9120 in the \code{habitatmap} do not refer to a
#' main type but to an non-defined subtype with no specific code).
#' (rbbkam, rbbzil & 9120 in the \code{habitatmap} do not refer to a
#' main type but to a non-defined subtype with no specific code).
#'
#'
#' @param x An object of class \code{data.frame}.
Expand Down Expand Up @@ -130,11 +130,26 @@ expand_types <- function(x,
assert_that(is.flag(use_grouping), noNA(use_grouping))
assert_that(is.flag(strict), noNA(strict))

types <-
read_types() %>%
select(1:3)

subtypes <-
types %>%
filter(.data$typelevel == "subtype") %>%
select(1, 3)

if (!all(unique(x[[type_var]]) %in% types$type)) {
warning("The data frame contains type codes which are not standard.")
}

if (!use_grouping) {
expand_types_plain(
x = x,
type_var = type_var,
strict = strict
strict = strict,
types = types,
subtypes = subtypes
)
} else {
x %>%
Expand All @@ -143,7 +158,9 @@ expand_types <- function(x,
mutate(newdata = map(.data$data,
expand_types_plain,
type_var = type_var,
strict = strict
strict = strict,
types = types,
subtypes = subtypes
)) %>%
select(-.data$data) %>%
unnest(cols = .data$newdata) %>%
Expand Down Expand Up @@ -186,31 +203,20 @@ expand_types <- function(x,
#' @keywords internal
expand_types_plain <- function(x,
type_var = "type",
strict = TRUE) {
types <-
read_types() %>%
select(1:3)

subtypes <-
types %>%
filter(.data$typelevel == "subtype") %>%
select(1, 3)

strict = TRUE,
types,
subtypes) {
orig_types <-
x[, type_var] %>%
rename(orig_abcd = type_var)

if (!all(unique(orig_types$orig_abcd) %in% types$type)) {
warning("The data frame contains type codes which are not standard.")
}

# main types to add:
suppressWarnings(
join_main_types <-
subtypes %>%
filter(.data$main_type == "2330" |
.data$type %in% c(
"6230_ha", "6230_hmo", "6230_hnk",
"6230_ha", "6230_hmo", "6230_hn",
"5130_hei",
"91E0_va", "91E0_vm", "91E0_vn"
)) %>%
Expand Down
9 changes: 8 additions & 1 deletion R/n2khab-deprecated.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@
#' - [`read_scheme_types()`] has moved to package `n2khabmon`.
#' Use [`n2khabmon::read_scheme_types()`] instead.
#'
#' @param ... arguments passed to the new function
#' An efficient way with base R to avoid function masking and conflict warnings
#' when attaching both `{n2khab}` and `{n2khabmon}`, regardless of the order
#' in which they're loaded, is by specifying something as below in your
#' script, at least _before_ loading `{n2khab}`:
#'
#' `conflictRules("n2khab", exclude = c("read_schemes", "read_scheme_types"))`
#'
#' @param ... Arguments passed to the new function.
#'
#' @md
#'
Expand Down
6 changes: 4 additions & 2 deletions R/options.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ n2khab_options <- function() {
),
"n2khab_use_raster",
tryCatch(
n2khab_using_raster(),
as.character(n2khab_using_raster()),
error = function(e) {
message(as.character(e))
NA
Expand Down Expand Up @@ -125,5 +125,7 @@ n2khab_using_raster <- function() {
if (identical(opt, "")) {
opt <- NA
}
opt || grepl("TRUE|true", opt)
(is.logical(opt) && length(opt) == 1 && opt) ||
identical(opt, "TRUE") ||
identical(opt, "true")
}
Loading

0 comments on commit 74bce51

Please sign in to comment.