Skip to contents

Plot a leaflet map representing cameras' coordinates as points.

Usage

plot_map(
  df,
  lat_col,
  lon_col,
  popup = NULL,
  display_camnames = FALSE,
  crs = 4326,
  width = NULL,
  height = NULL,
  cam_col,
  color = "black",
  radius = rep(3, nrow(df)),
  rescale = FALSE,
  label = NULL
)

Arguments

df

A dataframe containing cameras information

lat_col

Name of the latitude (or the projected y-coordinate) column

lon_col

Name of the longitude (or the projected y-coordinate) column

popup

A vector of characters to display in the popup for each camera. It must have the same length as the number of cameras in df and it must be ordered in the same way as the cameras in df.

display_camnames

Display camera names on the map?

crs

EPSG code for the coordinate reference system (CRS) Defaults to EPSG:4326, which is the code for WGS84 standard.

width

Map width

height

Map height

cam_col

Name of the camera name column

color

color for the points (can be a unique value or a character vector, in the same order as the rows of df)

radius

A vector of radii to use for the cirles. It can be named with names correspond to camera names. If it is not named, the labels are assumed to be in the same order as the cameras.

rescale

rescale circles? If TRUE, radii will be linearly resized so that the maximum corresponds to 300m, and radii smaller than 10 will be set to 10m.

label

vector of labels to display when hovering over the map points. It can be named with names correspond to camera names. If it is not named, the labels are assumed to be in the same order as the cameras.

Value

a leaflet map representing cameras as points. If the CRS of the input data is different from EPSG:4326 (WGS84), data are re-projected using WGS84. When hovering over a camera, it becomes red and its name is shown. When clicking on a camera, a popup displaying the camera name appears.

Examples

data(camtraps, package = "camtrapR")
plot_map(camtraps,
         lat_col = "utm_y", 
         lon_col = "utm_x",
         crs = 32650, # Here we use the EPSG code for UTM zone 50N
         cam_col = "Station")