Skip to contents

This function plot a GeoPressureR map object.

You can plot on top of the map a path, this uses the plot_path() function.

Our maps are defined in lat-lon (i.e., EPSG:4326), but the display of maps on web map are nearly always in web mercator (i.e., EPSG:3857). We therefore need to reproject our map for display. However, we don't really want to interpolate the map as each pixel might be important to visualize. We therefore re-project with a near-neighbour interpolation (method = "near" in terra::project()). Yet to avoid having pixel misplaced, we generally need to use a projection with a finer resolution. The argument fac_res_proj controls the relative change of resolution between the original map to the projected map.

Usage

# S3 method for map
plot(
  x,
  thr_likelihood = 1,
  path = NULL,
  plot_leaflet = TRUE,
  provider = "Esri.WorldTopoMap",
  provider_options = leaflet::providerTileOptions(),
  palette = "auto",
  opacity = 0.8,
  legend = FALSE,
  fac_res_proj = 4,
  ...
)

Arguments

x

a SpatRaster or a RasterLayer object--see raster

thr_likelihood

threshold of percentile (see details).

path

a GeoPressureR path data.frame

plot_leaflet

logical to use an interactive leaflet map instead of terra::plot

provider

the name of the provider (see https://leaflet-extras.github.io/leaflet-providers/preview/ and https://github.com/leaflet-extras/leaflet-providers)

provider_options

tile options. See leaflet::addProviderTiles() and leaflet::providerTileOptions()

palette

The colors or color function that values will be mapped to

opacity

the base opacity of the raster, expressed from 0 to 1

legend

logical or character. If not FALSE a legend is drawn. The character value can be used to indicate where the legend is to be drawn. For example "topright" or "bottomleft". Use plg for more refined placement. Not supported for continuous legends (the default for raster data)

fac_res_proj

Factor of the resolution of the reprojection (see details above). A value of 1 will roughly reproject on a map with similar size resulting in relatively high inaccuracy of the pixel displayed. Increasing this factor will reduce the uncertainty but might also increase the computational cost of the reprojection.

...

named parameters to add to the options

map

a GeoPressureR map object

Value

a plot or leaflet object.

See also

Examples

owd <- setwd(system.file("extdata", package = "GeoPressureR"))
tag <- tag_create("18LX", quiet = TRUE) |>
  tag_label(quiet = TRUE) |>
  tag_set_map(
    extent = c(-16, 23, 0, 50),
    scale = 4
  ) |>
  geopressure_map(quiet = TRUE)
setwd(owd)

plot(tag$map_pressure)
plot(tag$map_pressure, plot_leaflet = FALSE) # `thr_likelihood` can be used to visualize its effect in `graph_create` plot(tag$map_pressure, thr_likelihood = 0.9, palette = "viridis", opacity = 1, provider = "CartoDB.DarkMatterNoLabels" )