getNIdata: Read a Table in the NI Database

getNIdataR Documentation

Read a Table in the NI Database

Description

Functions that reads data from tables in the NI database via [The Nature Index Application Programming Interface](https://www8.nina.no/NaturindeksNiCalc/index.html) and imports the content as a data.frame.

Usage

getBSunits(BSunitIds = NULL)

getEcosystems()

getEcosystemBSunitData()

getFunctionalGroupData()

getICunits(indicatorIds = NULL)

getICunitBSunit(icunits = NULL)

getIndicators2(indicatorIds = NULL)

getIndicatorEcosystemData(ecosystemIds = NULL, indicatorIds = NULL)

getIndicatorValues2(indicatorIds = NULL, refYear = NULL)

getRefYearData()

getScalingModelData()

Arguments

BSunitIds

integer, optional.
getBSunits: Data for specified BSunits will be retrieved from the Kommune table. The default (NULL) is to retrieve data for all BSunits.

indicatorIds

integer, optional.
getIndicators2: Data for specified indicators will be retrieved from the Indikator table. The default (NULL) is to retrieve data for all indicators.
getIndicatorEcosystemData: Fidelity of specified indicators to all ecosystems or those given in ecosystemIds, will be retrieved from the Indikator_Okosystem table.
getICunits: ICunits for specified indicators will be retrieved from Omraade. The default (NULL) is to retrieve all ICunits.
getIndicatorValues2: Observations for specified indicators will be retrieved from Verdier. The default (NULL) is to retrieve no data.

icunits

integer, optional.
getICunitBSunit: Data for specified ICunits will be retrieved from the Omraade_Kommune table. The default (NULL) is to retrieve BSunits for all ICunits.

ecosystemIds

integer, optional.
getIndicatorEcosystemData: Fidelity of all indicators (or of those specified in indicatorIds) to the specified ecosystems, will be retrieved from the Indikator_Okosystem table. The default (ecosystemIds = NULL) is to retrieve fidelity of all indicators to all ecosystems.

refYear

character, optional.
getIndicatorValues2: Years of the observations to retrieve and whether to retreive reference values. E.g. refYear = c("2010","Referanseverdi") returns observations from 2010 together with reference values. Default = (NULL), which means you get all observations as well as reference values.

Details

Each function reads one table in the database:

Function Table in NI database Content Column names in returned dataframe
getBSunits Kommune Characteristics for all BSunits. [,1] "id",
[,2] "name",
[,3] "area",
[,4] "terrestrial",
[,5] "marine",
[,6] "county",
[,7] "part",
[,8] "centerLat",
[,9] "centerLong"
getEcosystems T_Okosystem Ecosystem names and ids. [,1] "id",
[,2] "name",
[,3] "nameEnglish".
getEcosystemBSunitData Kommune_Okosystem Area of major ecosystems [,1] "ecosystemId",
per BSunit [,2] "municipalityId",
[,3] "area".
getFunctionalGroupData T_FunksjonellGruppe names of functional groups [,1] "id",
[,2] "name",
[,3] "nameEnglish".
getICunits Omraade ICunit for each indicator [,1] "id",
[,2] "name",
[,3] "indicatorId".
getICunitBSunit Omraade_Kommune BSunits within each ICunit. [,1] "areaId",
[,2] "municipalityId".
getIndicators2 Indikator Characteristics for all indicators [, 1] "id",
[, 2] "active",
[, 3] "name",
[, 4] "nameEnglish",
[, 5] "nameLatin",
[, 6] "indicatorTypeId",
[, 7] "taxaDetailId",
[, 8] "functionalGroupId",
[, 9] "scalingModel",
[,10] "taxaKingdomId",
[,11] "keyElement",
[,12] "referenceStateId".
getIndicatorEcosystemData Indikator_Okosystem Fidelity of indicators [,1] "indicatorId",
per major ecosystem [,2] "ecosystemId",
[,3] "percent".
getIndicatorValues2 Verdier Reference values and [, 1] "indicatorId",
indicator observations [, 2] "indicatorName",
[, 3] "areaId",
[, 4] "areaName",
[, 5] "yearId",
[, 6] "yearName",
[, 7] "verdi",
[, 8] "nedre_Kvartil",
[, 9] "ovre_Kvartil",
[,10] "datatypeId",
[,11] "datatypeName",
[,12] "unitOfMeasurement",
[,13] "customDistributionUUID",
[,14] "distributionName",
[,15] "distributionId",
[,16] "distParam1",
[,17] "distParam2".
getRefYearData T_RefAar Ids for observation years and [,1] "id",
the reference value category [,2] "name",
[,3] "nameEnglish".
getScalingModelData T_Skaleringsmodell names of scaling models [,1] "id",
[,2] "name".

Value

All functions except getIndicatorValues2 returns a data frame with content according to the above table, or an error message if extraction of data from the database fails.

getIndicatorValues2 returns a list of two elements:
1) a data frame indicatorValues of indicator observations content according to the above table, and
2) a list customDistributions of optional distribution objects associated with some of the observations. Distribution objects are identified through the variable indicatorValues$customDistributionUUID

Note

Column names of returned objects are generated by the API and differ somewhat from the column headings in the corresponding table in the NI database.

Author(s)

Bård Pedersen

See Also

getToken for retrieving tokens from the Nature Index API, extractContentFromNiapi, a general purpose utility function called by the functions described here that retrieves data from the specified tables in the Nature Index database, and importDatasetApi for importing from the database all required data for calculating the Nature Index for an ecosystem.

Examples

## Not run: 
getBSunits()
getEcosystems()
getEcosystemBSunitData()
getFunctionalGroupData()
getICunits()
getICunitBSunit()
getIndicators2()
getIndicatorEcosystemData()
getIndicatorValues2(indicatorIds = 1:2,refYear = c("2010","Referanseverdi"))
getRefYearData()
getScalingModelData()

## End(Not run)


NINAnor/NIcalc documentation built on Oct. 26, 2023, 9:37 a.m.