The n2khab R package provides preprocessing functions and standard reference data, supporting reproducible and transparent analyses on Flemish Natura 2000 (n2k) habitats (hab) and regionally important biotopes (RIBs).
The package’s core aim is to provide readily standardized (preprocessed) data in your R environment. This facilitates collaboration and reproducibility.
The standard reference data include: checklists, spatial habitat distribution, administrative & environmental layers, GRTSmaster_habitats.
To install the current package version from the main
branch (latest stable release), run:
install.packages("n2khab", repos = c(inbo = "https://inbo.r-universe.dev",
CRAN = "https://cloud.r-project.org"))
The above provides a pre-compiled package for Windows and macOS,
which should be faster than below approach. INBO staff should have the
INBO repository enabled already (check with
getOption("repos")
), in which case
install.packages("n2khab")
is all you
need!
If you want to install from the source repository, run:
Sys.setenv(R_REMOTES_NO_ERRORS_FROM_WARNINGS = "true") # as a precaution
remotes::install_github("inbo/n2khab",
build_vignettes = TRUE,
upgrade = TRUE)
Note that this will install the package from the main
branch. If you need a version from another branch, add the
ref
argument in the above function to provide the branch
name.
Repeat the installation when you wish to upgrade.
Have a look at the vignettes to quickly find your way!
help(package = "n2khab")
# vignettes only: browseVignettes("n2khab")
# documentation of whole package: package?n2khab
Please take note that you must set up the needed data sources as
explained in vignette("v020_datastorage")
and demonstrated
in vignette("v022_example")
. There is a major distinction
between:
n2khab_data/10_raw
;n2khab_data/20_processed
.rgdal
warnings about proj4string
degradationSetting coordinate reference systems (CRS) of geospatial R objects is
taken care of by the package, in a way that is compatible with older and
current versions of PROJ and GDAL backend libraries. This is done by
gratefully implementing such features from the sf
and
sp
packages. The functions never specify a CRS by means of
a proj4string, which is an aged format not supported by the current
backend versions.
Please note that nonetheless you will see warnings about degraded
proj4strings when using certain n2khab
functions or when
converting resulting sf
objects to sp
objects.
This is normal! It is the current default behaviour of
rgdal
to yield these warnings. However in the case of
n2khab
functions and resulting objects these warnings are
trivial and unnecessary. You can suppress them in your R scripts by
inserting below statement before loading geospatial
packages:
options(rgdal_show_exportToProj4_warnings = "none")
See this tutorial if you would like to learn more about this. In short: don’t use proj4strings to define CRSs!
Please have a look at our contributing guide!
At a later date, the intention is to incorporate functionality to enhance workflow reproducibility and ease the setup:
Currently these aspects must be taken care of in a more manual
fashion. See vignette("v022_example")
for example code to
currently accomplish specific aspects.
From its aim, it follows that the package supports various N2KHAB projects, i.e. projects that focus on Natura 2000 habitat (and which may as well use the n2khab-prefix for their git repository name, such as this one).
The package is a companion to the n2khab-preprocessing
repo. Beside direct preprocessing functions, n2khab
provides several functions that return datasets, generated in
n2khab-preprocessing
, as standardized R-objects. Having
processed datasets readily available is useful in the case of
time-consuming calculations to produce them.
The data definitions & standard checklists (reference data)
provided by the package are textual files in the vc-format.
Some of them come over from another repository. Others may be written as
the result of a synchronization script to give them a start. The code to
reproduce these files is inside the misc
folder of the source code. The package
provides the necessary functions to return these as standardized tibbles
(vignette("v010_reference_lists")
).