Skip to contents

A provider is a function function(...) returning either an sf object or a data.frame, wide enough that its columns can be used as levels and weights.

Usage

geo_register_provider(name, fetch, levels = NULL, weights = NULL, desc = "")

Arguments

name

Provider name.

fetch

Function returning the source table.

levels

Default level columns, coarsest first.

weights

Default weight columns.

desc

One-line description.

Value

Invisibly, the registered provider.

Examples

geo_register_provider(
  "toy",
  fetch = function(...) data.frame(top = c("T", "T"),
                                   unit = c("a", "b"), km2 = c(1, 2)),
  levels = c("top", "unit"), weights = "km2"
)
geo_list_providers()
#>           name                                          desc
#> 1 naturalearth Natural Earth admin-0/admin-1 (rnaturalearth)
#> 2          toy