Type: | Package |
Title: | Retrieval and Processing of the Spanish National Forest Inventory |
Version: | 0.4.1 |
Date: | 2025-04-02 |
Maintainer: | Wilson Lara <wilarhen@gmail.com> |
Description: | Data sets of the Spanish National Forest Inventory https://www.miteco.gob.es/es/biodiversidad/servicios/banco-datos-naturaleza/informacion-disponible.html are processed to compute tree metrics and statistics. Function metrics2Vol() controls most of the routines. |
License: | GPL-3 |
Depends: | R (≥ 2.10),RODBC |
Imports: | curl,foreign,Hmisc,httr,measurements,stats,utils |
NeedsCompilation: | no |
Packaged: | 2025-04-02 18:42:36 UTC; wihe |
Repository: | CRAN |
Date/Publication: | 2025-04-02 19:00:02 UTC |
Author: | Wilson Lara |
DBH metrics
Description
This function can format tree diameters at breast height and tree
heights according to the sampling design of the Spanish National
Forest Inventory (SNFI). The function is used by other routines of
basifoR
to derive tree metrics, see Details
section. Implementation of this function using data sets of the
SNFI can be burdensome. Use dendroMetrics
instead to
recursively derive tree metrics.
Usage
dbhMetric(dbh, met = "d")
Arguments
dbh |
|
met |
|
Details
Replicates of tree diameter
'd'
are averaged. The tree heights
'h'
are formatted from mm
to
dm
for further evaluation of volume
equations. The basal areas are computed
transforming the diameters from mm
to
cm
and using the formula: ba (m2
tree-1 ha-1) = pi * d(cm)^2 * (4 *
1E4)^-1
. The number of trees per hectare
'n'
are calculated considering the
sample design of the NFI: each plot consists
of four concentric subplots with radii
5, 10, 15,
and 25 m
. The
minimum diameters recorded in the subplots
are 7.5, 12.5, 22.5,
and 42.5
cm
respectively. Considering these, any of
four estimates is printed: 127.32,
31.83, 14.15
, or 5.09
.
Value
numeric
. A tree metric: mean diameter (mm
), tree basal area
(m2 tree-1
), number of trees (dimensionless), or
tree height (dm
).
Author(s)
Wilson Lara <wilarhen@gmail.com> [aut, cre] (<https://orcid.org/0000-0003-3527-1380>), Cristobal Ordonez <a_cristo@pvs.uva.es> [aut] (<https://orcid.org/0000-0001-5354-3760>), Felipe Bravo <fbravo@pvs.uva.es> [aut] (<https://orcid.org/0000-0001-7348-6695>)
Examples
dbh <- dbhMetric(c(10.7, 11.5), 'h')# average tree height (dm)
Summarize dendrometrics
Description
This function can summarize dendrometric data of the Spanish National Forest Inventory (SNFI). It can also control most other functions of the package. Dendrometric variables in the outputs are transformed into stand units, see the Details section.
Usage
dendroMetrics(nfi, summ.vr = "Estadillo",
cut.dt = "d == d",
report = FALSE, ...)
Arguments
nfi |
|
summ.vr |
|
cut.dt |
|
report |
|
... |
Additional arguments in |
Details
Dendrometric variables are
summarized according to the levels of
the argument summ.vr
. The summary
outputs include the categorical columns
formulated in summ.vr
and the
variables defined using
arguments/defaults in
nfiMetrics
. These
variables include the tree basal area
ba
('m2 ha-1'
), the
average diameter at breast height
d
('cm'
), the quadratic
mean diameter dg
('cm'
),
the average tree height h
('m'
), the number of trees by
hectare n
('dimensionless'), and
the over bark volume v
('m3
ha-1'
). Subsets of the output summary
are extracted using logical expressions
in argument 'cut.dt'
, see syntax
in Logic
.
Value
data.frame
. Depending on summ.vr = NULL
, an output from
metrics2Vol
, or a summary of the variables, see
Details section.
Author(s)
Wilson Lara <wilarhen@gmail.com> [aut, cre] (<https://orcid.org/0000-0003-3527-1380>), Cristobal Ordonez <a_cristo@pvs.uva.es> [aut] (<https://orcid.org/0000-0001-5354-3760>), Felipe Bravo <fbravo@pvs.uva.es> [aut] (<https://orcid.org/0000-0001-7348-6695>)
Examples
## SNFI Data from the province of Madrid
madridNFI <- system.file("ifn3p28_tcm30-293962.zip", package="basifoR")
rmad <- readNFI(madridNFI)[1:100,]
mmad <- nfiMetrics(rmad)
vmad <- metrics2Vol(mmad)
dmad <- dendroMetrics(vmad, cut.dt = 'h > 8')
head(dmad)
## see metric units
attr(dmad,'units')
## Retrieval of SNFI data in 'www.miteco.gob.es' and computation
## of the corresponding dendrometric summary:
## donttest{
## path <- '/es/biodiversidad/servicios/banco-datos-naturaleza/090471228013cbbd_tcm30-278511.zip'
## url2 <- httr::modify_url("https://www.miteco.gob.es", path = path)
## dmad <- dendroMetrics(url2, cut.dt = 'h >= 11')
## head(dmad)
## attr(dmad, 'units')
## }
Tree volumes in NFI data
Description
This function computes over bark volumes ('m3'
) processing
tree metrics from databases of the SNFI data and using volume
equations established in 2nd NFI, see Details section. To derive
dendrometric summaries use dendroMetrics
.
Usage
metrics2Vol(nfi, cub.met = "freq",
keep.var = FALSE,
...)
Arguments
nfi |
|
cub.met |
|
keep.var |
|
... |
Depending on |
Details
The quations from the second SNFI
used have the forms 'v ~ par1 + par2
* (d^2) * h'
, and 'v ~ par1 *
(d^par2) * (h^par3)'
. These equations
estimate over bark volumes in 'dcm3'
but the function transform the units so the
output volumes have 'm3'
units. The
function assign equation forms and
parameters depending on several variables,
including the provincial unit, the tree
species, the tree diameter, and the tree
height. Consequently, objects from
nfiMetrics
must have these
variables.
Value
data.frame
. Depending on keep.var
, short or expanded
data set. Short data sets contain the volumes v
('m3'
) plus the metrics defined in
nfiMetrics
. The expanded data contains additional
columns with the variables used to compute the volumes.
Author(s)
Wilson Lara <wilarhen@gmail.com> [aut, cre] (<https://orcid.org/0000-0003-3527-1380>), Cristobal Ordonez <a_cristo@pvs.uva.es> [aut] (<https://orcid.org/0000-0001-5354-3760>), Felipe Bravo <fbravo@pvs.uva.es> [aut] (<https://orcid.org/0000-0001-7348-6695>)
Examples
madridNFI <- system.file("ifn3p28_tcm30-293962.zip", package="basifoR")
rmad <- readNFI(madridNFI)[1:10,]
vmad <- metrics2Vol(rmad)
head(vmad)
## see metric units
attr(vmad,'units')
Tree metrics from NFI data
Description
This function recursively implements dbhMetric
on
data bases of the Spanish National Forest Inventory (NFI) to
derive a variety of tree metrics. Use metrics2Vol
to
recursively derive the metrics plus over bark volumes.
Usage
nfiMetrics(nfi, var = c("d",
"h", "ba", "n", "Hd"),
levels = c("esta",
"espe"), ...)
Arguments
nfi |
|
var |
|
levels |
|
... |
Additional arguments in |
Value
data.frame
containing columns which match the strings in
levels
, plus the variables defined in var
, including
the province pr
(dimensionless
), the diameter
d
('mm'
), the tree height h
('dm'
),
the basal area ba
('m2 tree-1'
), the number of trees
by hectare n
(dimensionless
), and the tree dominant
height Hd
('m'
).
Author(s)
Wilson Lara <wilarhen@gmail.com> [aut, cre] (<https://orcid.org/0000-0003-3527-1380>), Cristobal Ordonez <a_cristo@pvs.uva.es> [aut] (<https://orcid.org/0000-0001-5354-3760>), Felipe Bravo <fbravo@pvs.uva.es> [aut] (<https://orcid.org/0000-0001-7348-6695>)
Examples
## seconf NFI
madridNFI <- system.file("ifn3p28_tcm30-293962.zip", package="basifoR")
rmad <- readNFI(madridNFI)[1:10,]
mmad <- nfiMetrics(rmad)
head(rmad,3)
## see metric units
attr(rmad,'units')
Read NFI data
Description
This function can retrieve data sets of the Spanish National
Forest Inventory (SNFI). It can process either URLs
to data
stored in the SNFI web page ("http://www.miteco.gob.es"
) or
paths to files locally stored.
Usage
readNFI(nfi, dt.nm = "PCMayores",
...)
Arguments
nfi |
|
dt.nm |
|
... |
Additional arguments in |
Details
Compressed data having file
extensions other than .dbf
or
.mdb
are not supported. Most data bases
in 2nd
and 3rd
stages of the
SNFI can be imported directly from
http://www.miteco.gob.es
using
appropriate URLs
. Data sets from 2nd
SNFI are imported using
read.dbf
. Data from latter
stages are imported using either
odbcConnect
(Windows) or
mdb.get
(unix-alike
systems). Data from 4th SNFI must be read from
local paths. On Windows, a driver for Office
2010 can be installed via the installer
'AccessDatabaseEngine.exe'
available
from Microsoft, and the package must be
implemented using a 32-bit R version. In the
case of unix-alike systems, the linux
dependence mdbtools
must be installed.
Value
data.frame
. A data base of the NFI.
Author(s)
Wilson Lara <wilarhen@gmail.com> [aut, cre] (<https://orcid.org/0000-0003-3527-1380>), Cristobal Ordonez <a_cristo@pvs.uva.es> [aut] (<https://orcid.org/0000-0001-5354-3760>), Felipe Bravo <fbravo@pvs.uva.es> [aut] (<https://orcid.org/0000-0001-7348-6695>)
Examples
madridNFI <- system.file("ifn3p28_tcm30-293962.zip", package="basifoR")
rmad <- readNFI(madridNFI)[1:100,]
head(rmad)
## Retrieval of a data base from the second stage of the second SNFI:
## donttest{
## path <- '/es/biodiversidad/servicios/banco-datos-naturaleza/090471228013cbbd_tcm30-278511.zip'
## url2 <- httr::modify_url("https://www.miteco.gob.es", path = path)
## rnfi <- readNFI(url2)
## head(rnfi,3)
## }
Temporary NFI data
Description
This function is implemented by other routines of the package to
decompress .zip
files with data sets of the SNFI.
Usage
urlToTemp(url., timeOut = timeout(60))
Arguments
url. |
|
timeOut |
|
Details
The data sets are decompressed in a
temporary file of the local
machine. Compressed data containing file
extensions other than .mdb
or
.dbf
are not supported.
Value
character
. Path to the NFI data (.mdb or .dbf) stored in a
temporary file
Author(s)
Wilson Lara <wilarhen@gmail.com> [aut, cre] (<https://orcid.org/0000-0003-3527-1380>), Cristobal Ordonez <a_cristo@pvs.uva.es> [aut] (<https://orcid.org/0000-0001-5354-3760>), Felipe Bravo <fbravo@pvs.uva.es> [aut] (<https://orcid.org/0000-0001-7348-6695>)
Examples
madridNFI <- system.file("ifn3p28_tcm30-293962.zip", package="basifoR")
tfmad <- urlToTemp(madridNFI)
tfmad
## Internet resources fail gracefully with an informative message if
## the resource is not available or has changed (and not give a check
## warning nor error):
path <- '/es/biodiversidad/servicios/banco-datos-naturaleza/090471228013cbbd_tcm30-278511.zip'
url2 <- httr::modify_url("https://www.miteco.gob.es", path = path)
tfmad <- urlToTemp(url2, timeOut=timeout(1))