Learn R Programming

leafem - leaflet extensions for mapview

leafem provides extensions for package leaflet many of which are used by package mapview. The intention of this package is to enhance leaflet functionality to provide a more GIS-like feeling when plotting spatial data interactively.

Installation

You can install the released version of leafem from CRAN with:

install.packages("leafem")

Extensions

addFeatures

library(leaflet)

leaflet() %>% addProviderTiles("OpenStreetMap") %>% addFeatures(data = breweries91)

addMouseCoordinates

leaflet() %>%
  addProviderTiles("OpenStreetMap") %>%
  addMouseCoordinates()

garnishMap

library(leaflet)

m <- leaflet() %>% addProviderTiles("OpenStreetMap")
garnishMap(m, addMouseCoordinates)

addHomeButton

library(leaflet)
library(raster)

m <- leaflet() %>%
  addProviderTiles("OpenStreetMap") %>%
  addCircleMarkers(data = breweries91) %>%
  addHomeButton(extent(breweries91), "breweries91")
m

addImageQuery

library(leaflet)
library(plainview)

leaflet() %>%
  addProviderTiles("OpenStreetMap") %>%
  addRasterImage(poppendorf[[1]], project = TRUE, group = "poppendorf",
                 layerId = "poppendorf") %>%
  addImageQuery(poppendorf[[1]], project = TRUE,
                layerId = "poppendorf") %>%
  addLayersControl(overlayGroups = "poppendorf")

addLogo

img <- "https://www.r-project.org/logo/Rlogo.svg"

leaflet() %>% addTiles() %>% addLogo(img, url = "https://www.r-project.org/logo/")

Code of Conduct

Please note that the ‘leafem’ project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Copy Link

Version

Install

install.packages('leafem')

Monthly Downloads

21,574

Version

0.2.3

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Tim Appelhans

Last Published

September 17th, 2023

Functions in leafem (0.2.3)

addLogo

add a local or remote image (png, jpg, gif, bmp, ...) to a leaflet map
addMouseCoordinates

Add mouse coordinate information at top of map.
addPMPolygons

Add vector tiles stored as PMTiles in an AWS S3 bucket to a leaflet map.
garnishMap

Garnish/decorate leaflet or mapview maps.
addRasterRGB

Add an RGB image as a layer
colorOptions

Color options for addGeoRaster and addGeotiff
paintRules

Styling options for PMTiles
addTileFolder

Add raster tiles from a local folder
updateLayersControl

Update the layer controls when adding layers to an existing map.
addStaticLabels

Add static labels to leaflet or mapview objects
addLocalFile

Add vector data to leaflet map directly from the file system
addImageQuery

Add image query functionality to leaflet/mapview map.
addCopyExtent

Copy current view extent to the clipboard
addFeatures

Type agnositc version of leaflet::add* functions.
addCOG

Add Cloud Optimised Geotiff (COG) to a leaflet map.
addGeoRaster

Add stars/raster image to a leaflet map using optimised rendering.
addGeotiff

Add a GeoTIFF file to a leaflet map using optimised rendering.
addExtent

Add extent/bbox of spatial objects to a leaflet map
addFgb

Add a flatgeobuf file to leaflet map
addHomeButton

Add a home button / zoom-to-layer button to a map.
addReactiveFeatures

Add a reactive layer to map.
addStarsImage

Add stars layer to a leaflet map