Initiate a geospatial database or register a database that exists at the root path.

adb_init(root, version, author, licence, gazetteer, top, ontology)

Arguments

root

[character(1)]
path to the root directory that contains or shall contain an areal database.

version

[character(1)]
version identifier for this areal database.

author

[character(1)]
authors that contributed to building this areal database. Should be a list with items "cre" (creator), "aut" (authors) and "ctb" (contributors).

licence

[character(1)]
licence (link) for this areal database.

gazetteer

[character(1)]
path to the gazetteer that holds the (hierarchical) information of territorial units used in this database.

top

[character(1)]
the label of the class in the gazetteer that represents the top-most unit (e.g. country) of the areal database that shall be started.

ontology

[list(.)]
named list with the path(s) of ontologies, where the list name identifies the variable that shall be matched with the ontology at the path.

Value

No return value, called for the side effect of creating the directory structure of the new areal database and tables that contain the database metadata.

Details

This is the first function that is run in a project, as it initiates the areal database by creating the default sub-directories and initial inventory tables. When a database has already been set up, this function is used to register that path in the options of the current R session.

Examples

adb_init(root = paste0(tempdir(), "/newDB"),
         version = "1.0.0", licence = "CC-BY-0.4",
         author = list(cre = "Gordon Freeman", aut = "Alyx Vance", ctb = "The G-Man"),
         gazetteer = paste0(tempdir(), "/newDB/territories.rds"),
         top = "al1",
         ontology = list(var = paste0(tempdir(), "/newDB/ontology.rds")))
#> Warning: no gazetteer was found in the provided path!
#> creating root directory /tmp/RtmpCPQnWD/newDB
#> creating .../tables
#> creating .../tables/stage1
#> creating .../tables/stage2
#> creating .../tables/stage2/processed
#> creating .../tables/stage3
#> creating .../geometries
#> creating .../geometries/stage1
#> creating .../geometries/stage2
#> creating .../geometries/stage2/processed
#> creating .../geometries/stage3
#> creating .../meta
#> creating .../meta/schemas
#> creating .../meta/documentation
#> creating .../meta/territories
#> copying gazetteer to .../meta/territories.rds
#> creating .../meta/ontology
#> copying ontology to .../meta/ontology.rds
#> creating .../meta/inventory.rds
#> creating .../adb_info.RData

getOption("adb_path"); getOption("gazetteer_path")
#> [1] "/tmp/RtmpCPQnWD/newDB"
#> [1] "/tmp/RtmpCPQnWD/newDB/meta/territories.rds"