Learn R Programming

leafletR (version 0.2-1)

leafletR-package: Interactive web-maps based on the Leaflet JavaScript library

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.

Arguments

encoding

UTF-8

Details

lll{ Package: leafletR Type: Package Version: 0.2-1 Date: 2014-07-09 License: GPL (>=2) } 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, the package 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 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 uses open base map tiles only. Map data is provided by the http://www.openstreetmap.org{OpenStreetMap} project and satellite images are provided by courtesy of NASA/ JPL-Caltech and U.S. Department of Agriculture, Farm Service Agency.

Try the example below to check if leafletR has been correctly installed. Any question and feedback is welcome via email to .

Example output:

quakes.png
{options: width=390px}

References

http://leafletjs.com

Examples

Run this code
# 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
#browseURL(q.map)

Run the code above in your browser using DataLab