leafletR-package: Interactive Web-Maps Based on the Leaflet JavaScript Library

Description Details Author(s) References Examples

Description

Display your spatial data on interactive web-maps using the open-source JavaScript library Leaflet. The package provides basic web-mapping functionality to combine vector data and online map tiles from different sources.

Details

leafletR lets you display spatial data on interactive maps in web browsers (a.k.a. slippy maps). It takes advantage of the open-source JavaScript library Leaflet.js, developed by Vladimir Agafonkin. Focusing simplicity, leafletR provides basic web-mapping functionality and styling options only. For map display an internet connection is required to load the Leaflet library, stylesheets and base map tiles. The ready to use html file output can be viewed locally or uploaded to a web-server.

leafletR supports GeoJSON and TopoJSON files directly. Additionally it contains conversion tools for sp spatial objects, several popular spatial vector data formats and R data frames containing point coordinates.

leafletR features open base map tiles. Map data is provided by the OpenStreetMap project and satellite images are provided by courtesy of NASA/ JPL-Caltech and U.S. Department of Agriculture, Farm Service Agency. Other tile sources may be added manually.

Try the example below to check if leafletR has been correctly installed. Any question and feedback is welcome via email to <christian.graul@gmail.com> or on GitHub.

Example output:

Author(s)

Christian Graul, with contributions from Francois Guillem

Maintainer: Christian Graul <christian.graul@gmail.com>

References

http://leafletjs.com http://geojson.org https://github.com/topojson/topojson-specification

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# load example data (Fiji Earthquakes)
data(quakes)

# store data in GeoJSON file (just a subset here)
q.dat <- toGeoJSON(data=quakes[1:99,], dest=tempdir(), name="quakes")

# make style based on quake magnitude
q.style <- styleGrad(prop="mag", breaks=seq(4, 6.5, by=0.5), 
  style.val=rev(heat.colors(5)), leg="Richter Magnitude", 
  fill.alpha=0.7, rad=8)

# create map
q.map <- leaflet(data=q.dat, dest=tempdir(), title="Fiji Earthquakes", 
  base.map="mqsat", style=q.style, popup="mag")

# view map in browser
#q.map

Example output

 
This is leafletR 0.4-0
 
Type changes("leafletR") to see changes/bug fixes, help(leafletR) for documentation
or citation("leafletR") for how to cite leafletR.
 

Attaching package: 'leafletR'

The following object is masked from 'package:methods':

    getProperties

Columns 1 (lat) and 2 (long) detected as latitude and longitude

File saved under /work/tmp/tmp/RtmpOMRzGP/quakes.geojson

Your leaflet map has been saved under /work/tmp/tmp/RtmpOMRzGP/Fiji_Earthquakes/Fiji_Earthquakes.html

leafletR documentation built on May 2, 2019, 10:25 a.m.