Generate a random population of consumers and providers.

simulate_catchments(n = 100, weight = 1, ..., consumers_range = c(10,
  5000), long_center = -99, long_spread = 1, lat_center = 40,
  lat_spread = 1, as_sf = TRUE)

Arguments

n

Number of consumers to generate.

weight

Weight method used on Euclidean distances between consumers and providers.

...

Passes additional arguments to catchment_weight.

consumers_range

A numeric vector with entries for minimal and maximal consumer counts from which to sample.

long_center

Longitude to randomly place consumers around.

long_spread

Standard deviation of the consumer's longitude distribution.

lat_center

Latitude to randomly place consumers around.

lat_spread

Standard deviation of the consumer's latitude distribution.

as_sf

Logical; if FALSE, consumer and provider data are returned in regular data.frames.

Value

A list with consumers, providers, cost, and weight entries.

Examples

pop <- simulate_catchments()
if (require("leaflet", quiet = TRUE)) {
  leaflet(pop$providers) |>
    addCircles(
      radius = 1e5, color = "#666", stroke = FALSE
    ) |>
    addCircles(
      data = pop$consumers, label = ~ paste0("Consumers: ", count, ", Access: ", access)
    ) |>
    addCircles(
      color = "#000", label = ~ paste("Provider", id)
    )
}