Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

addLocalFile

Add vector data to leaflet map directly from the file system


Description

Add vector data to leaflet map directly from the file system

Usage

addLocalFile(
  map,
  file,
  layerId = NULL,
  group = NULL,
  popup = NULL,
  label = NULL,
  radius = 10,
  stroke = TRUE,
  color = "#03F",
  weight = 5,
  opacity = 0.5,
  fill = TRUE,
  fillColor = color,
  fillOpacity = 0.2,
  dashArray = NULL,
  options = NULL
)

Arguments

map

a mapview or leaflet object.

file

file path to the file to be added to map. NOTE: will be reprojected on-the-fly if not in "longlat".

layerId

the layer id.

group

the group name for the file to be added to map.

popup

either a logical of whether to show the feature properties (fields) in popups or the name of the field to show in popups.

label

name of the field to be shown as a tooltip.

radius

the size of the circle markers.

stroke

whether to draw stroke along the path (e.g. the borders of polygons or circles).

color

stroke color.

weight

stroke width in pixels.

opacity

stroke opacity.

fill

whether to fill the path with color (e.g. filling on polygons or circles).

fillColor

fill color.

fillOpacity

fill opacity.

dashArray

a string that defines the stroke dash pattern.

options

a list of extra options for tile layers, popups, paths (circles, rectangles, polygons, ...), or other map elements.

Examples

if (interactive()) {
  library(leafem)
  library(leaflet)
  library(sf)

  destfile = tempfile(fileext = ".gpkg")

  st_write(st_as_sf(gadmCHE), dsn = destfile)

  leaflet() %>%
    addTiles() %>%
    addLocalFile(destfile, popup = TRUE)
}

leafem

'leaflet' Extensions for 'mapview'

v0.1.3
MIT + file LICENSE
Authors
Tim Appelhans [cre, aut], Christoph Reudenbach [ctb], Kenton Russell [ctb], Jochen Darley [ctb], Daniel Montague [ctb] (Leaflet.EasyButton plugin), Lorenzo Busetto [ctb], Luigi Ranghetti [ctb], Miles McBain [ctb], Sebastian Gatscha [ctb], Björn Harrtell [ctb] (FlatGeobuf plugin), Daniel Dufour [ctb] (georaster-layer-for-leaflet)
Initial release
2020-07-19

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.