Skip to contents

Registers a custom resource function to access data or functionality otherwise not native to mapme.biodiversity to be used with get_resources(). Custom resources will also be registered in the list generated by available_resources().

Usage

register_resource(
  name = NULL,
  type = NULL,
  source = NULL,
  fun = NULL,
  arguments = list()
)

Arguments

name

A character vector indicating the name of the resource.

type

A character vector indicating the type of the resource. Either 'vector' or 'raster'.

source

Optional, preferably a URL where the data is found.

fun

The function you wish to register.

arguments

A list with named entries indicating the default values for the arguments required by the function

Value

Nothing. Registers the function in the package environment.

Details

Note that registering your own resource function will only have effect for the current R session. If you return to your analysis in a new session, you will have to re-register your custom resource.

Examples

# \dontrun{
register_resource(
  name = "gfw_treecover",
  type = "raster",
  source = "https://data.globalforestwatch.org/documents/tree-cover-2000/explore",
  fun = .get_gfw_treecover,
  arguments = list(vears_treecover = "GFC-2021-v1.9")
)
#> Error in eval(expr, envir, enclos): object '.get_gfw_treecover' not found
# }