Learn R Programming

mapr (version 0.5.2)

hull: Add a convex hull to a map

Description

Add a convex hull to a map

Usage

hull(x, ...)

Arguments

x

input

...

ignored

Value

Adds a convex hull to the plot. See grDevices::chull() for info.

Details

Can be used with map_leaflet(), map_plot(), and map_ggplot(). Other methods in this package may be supported in the future.

Examples

Run this code
# NOT RUN {
# map spocc output, here using a built in object
data(occdat_eg1)
map_plot(occdat_eg1, hull = TRUE)

# map rgbif output, here using a built in object
hull(map_ggplot(occdat_eg1))

# }
# NOT RUN {
# leaflet
library("spocc")
spp <- c('Danaus plexippus', 'Accipiter striatus', 'Pinus contorta')
dat <- occ(spp, from = 'gbif', limit = 30, has_coords = TRUE)
hull(map_leaflet(dat))

# ggplot
if (requireNamespace("rgbif")) {
library("rgbif")
res <- occ_search(scientificName = "Puma concolor", limit = 100)
hull(map_ggplot(res))
}

# base plots
library("spocc")
out <- occ(query='Accipiter striatus', from='gbif', limit=25,
  has_coords=TRUE)
map_plot(out, hull = TRUE)
# }

Run the code above in your browser using DataLab