Learn R Programming

arealDB (version 0.3.9)

regTable: Register a new areal data table

Description

This function registers a new areal data table into the geospatial database.

Usage

regTable(
  nation = NULL,
  subset = NULL,
  dSeries = NULL,
  gSeries = NULL,
  level = NULL,
  begin = NULL,
  end = NULL,
  schema = NULL,
  archive = NULL,
  archiveLink = NULL,
  nextUpdate = NULL,
  updateFrequency = NULL,
  metadataLink = NULL,
  metadataPath = NULL,
  notes = NULL,
  update = FALSE,
  overwrite = FALSE
)

Arguments

nation

[character(1)] the nation for which the areal data are valid.

subset

[character(1)] optional argument to specify which subset the file contains. This could be a subset of territorial units (e.g. only one municipality) or of a target variable.

dSeries

[character(1)] the dataseries of the areal data (see regDataseries).

gSeries

[character(1)] optionally, the dataseries of the geometries, if the geometry dataseries deviates from the dataseries of the areal data (see regDataseries).

level

[integerish(1)] the administrative level at which the boundaries are recorded.

begin

[integerish(1)] the date from which on the data are valid.

end

[integerish(1)] the date until which the data are valid.

schema

[list(1)] the schema description of the table to read in (must have been placed in the global environment before calling it here).

archive

[character(1)] the original file from which the boundaries emerge.

archiveLink

[character(1)] download-link of the archive.

nextUpdate

[character(1)] when does the geometry dataset get updated the next time (format restricted to: YYYY-MM-DD).

updateFrequency

[character(1)] value describing the frequency with which the dataset is updated, according to the ISO 19115 Codelist, MD_MaintenanceFrequencyCode. Possible values are: 'continual', 'daily', 'weekly', 'fortnightly', 'quarterly', 'biannually', 'annually', 'asNeeded', 'irregular', 'notPlanned', 'unknown', 'periodic', 'semimonthly', 'biennially'.

metadataLink

[character(1)] if there is already metadata existing: link to the meta dataset.

metadataPath

[character(1)] if an existing meta dataset was downloaded along the data: the path where it is stored locally.

notes

[character(1)] optional notes.

update

[logical(1)] whether or not the file 'inv_tables.csv' should be updated.

overwrite

[logical(1)] whether or not the geometry to register shall overwrite a potentially already existing older version.

Value

Returns a tibble of the entry that is appended to 'inv_tables.csv' in case update = TRUE.

Details

When processing areal data tables, carry out the following steps:

  1. Determine the nation, a subset (if applicable), the administrative level and the dataseries of the areal data and of the geometry, and provide them as arguments to this function.

  2. Provide a begin and end date for the areal data.

  3. Run the function.

  4. (Re)Save the table with the following properties:

    • Encoding: UTF-8

    • File name: What is provided as message by this function

    • make sure that the file is not modified or reshaped. This will happen during data normalisation via the schema description, which expects the original table.

  5. Confirm that you have saved the file.

Every areal data dataseries (dSeries) may come as a slight permutation of a particular table arrangement. The function normTable expects internally a schema description (a list that describes the position of the data components) for each data table, which is saved as paste0("meta_", dSeries, TAB_NUMBER). See package tabshiftr.

Examples

Run this code
# NOT RUN {
# build the example database
makeExampleDB(until = "regGeometry")

# the schema description for this table
library(tabshiftr)
library(magrittr)

schema_madeUp <-
  setIDVar(name = "al1", columns = 1) %>%
  setIDVar(name = "year", columns = 2) %>%
  setIDVar(name = "commodities", columns = 3) %>%
  setObsVar(name = "harvested",
            factor = 1, columns = 4) %>%
  setObsVar(name = "production",
            factor = 1, columns = 5)

regTable(nation = "Estonia",
         subset = "barleyMaize",
         dSeries = "madeUp",
         gSeries = "gadm",
         level = 1,
         begin = 1990,
         end = 2017,
         schema = schema_madeUp,
         archive = "example_table.7z|example_table1.csv",
         archiveLink = "...",
         nextUpdate = "2019-10-01",
         updateFrequency = "quarterly",
         metadataLink = "...",
         metadataPath = "my/local/path",
         update = TRUE)
# }

Run the code above in your browser using DataLab