Learn R Programming

bfsMaps (version 0.9.6)

RequireMap: Ensure Availability of a Map

Description

LoadMap directly looks up the path of a map based on a shortcut name or number, loads the map from this location and return the object. RequireMap does the same, but if the map has been loaded before, it returns the temporarily cached copy. The reason for this is that loading the map objects appears to be computationally intensive. It takes relatively long and should not have to be done every time we need a map.

Usage

RequireMap(name_x, verbose = FALSE)

LoadMap(name_x, basedir = getOption("bfsMaps.base", default = file.path(find.package("bfsMaps"), "extdata")))

Arguments

name_x

the name of a map, currently supported are "kant.map", "bezk.map", "polg.map", "greg.map", "ch.map" or any number referring to a row in the 'maps.csv' file.

verbose

the function will return the result invisibly, unless verbose is set to TRUE.

basedir

the root directory for the maps to reside. bfsMaps by default looks for the mapfiles in it's install location in the extdata directory. The basedir can be set as an option too.

Value

the map object

Details

The maps are loaded to the package's environment as soon as they are used the first time in the session. Later access is so made considerably faster.

Examples

Run this code
# NOT RUN {
# use map containing Swiss metropolitan regions
mymap <- RequireMap(78)
plot(mymap, col=Pal("Helsana"))
# }

Run the code above in your browser using DataLab