Skip to contents

allocation_plot() plot the results of the allocation and allocation_discrete() functions, showing the potential locations for new facilities and the coverage attained.

Usage

allocation_plot(
  allocation,
  bb_area,
  annotation_location = "br",
  annotation_scale = TRUE,
  annotation_north_arrow = TRUE
)

Arguments

allocation

The output of the allocation or allocation_discrete() function.

bb_area

A sf boundary box object with the area of interest.

annotation_location

(optional) A character string specifying the location of the annotation on the plot. See annotation_scale for possible values (default: "br").

annotation_scale

(optional) A logical flag indicating whether to include a scale annotation on the plot (default: TRUE).

annotation_north_arrow

(optional) A logical flag indicating whether to include a north arrow annotation on the plot (default: TRUE).

Value

A ggplot2 plot showing the potential locations for new facilities.

Examples


## Plotting Results of the `allocation()` Function -----

if (FALSE) { # \dontrun{
  traveltime_data <-
    naples_fountains |>
    traveltime(
      bb_area = naples_shape,
      dowscaling_model_type = "lm",
      mode = "walk",
      res_output = 100
    )

  allocation_data <-
    naples_population |>
    allocation(
      traveltime = traveltime_data,
      bb_area = naples_shape,
      facilities = naples_fountains,
      weights = NULL,
      objectiveminutes = 15,
      objectiveshare = 0.99,
      heur = "max",
      dowscaling_model_type = "lm",
      mode = "walk",
      res_output = 100
    )

  allocation_data |> allocation_plot(naples_shape)
} # }

## Plotting Results of the `allocation_discrete()` Function -----

if (FALSE) { # \dontrun{
  library(sf)

  traveltime_data <-
    naples_fountains |>
    traveltime(
      bb_area = naples_shape,
      dowscaling_model_type = "lm",
      mode = "walk",
      res_output = 100
    )

  allocation_data <-
    naples_population |>
    allocation_discrete(
      traveltime = traveltime_data,
      bb_area = naples_shape,
      facilities = naples_fountains,
      candidate = naples_shape |> st_sample(20),
      n_fac = 2,
      weights = NULL,
      objectiveminutes = 15,
      dowscaling_model_type = "lm",
      mode = "walk",
      res_output = 100,
      n_samples = 1000,
      par = TRUE
    )

  allocation_data |> allocation_plot(naples_shape)
} # }