Learn R Programming

smartmap

smartmap is a package for previewing spatial data as leaflet maps in R. It is designed primarily for interactive use and produces nice maps with minimal setup required. In contrast to other similar packages, smartmap does not require an sf or sp object as input, but just works with normal data.frames or matrices that have longitude and latitude columns. See the function reference for more info.

Installation

And the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("s-fleck/smartmap")

Example

library(smartmap)

# coordinate pairs without names are interpreted as longitude/latitude
smap(c(16.422524, 48.185686))

# if you supply column names, smap uses those to identify the correct columns
smap(c(LAT = 48.185686, LoNgItuDE = 16.422524))

# when supplied with an url or file system path, smap tries its best to discover
# supported spatial datasets
smap("https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/50m/cultural/ne_50m_admin_0_countries.zip")

# You can call smap() on existing leaflet objects to add background tiles and
# a ruler for measuring distance
library(leaflet)
lf <- leaflet::leaflet() %>% 
  leaflet::addCircleMarkers(lng = 16.422524, lat = 48.185686)

lf
smap(lf)

Copy Link

Version

Install

install.packages('smartmap')

Monthly Downloads

328

Version

0.1.1

License

MIT + file LICENSE

Maintainer

Stefan Fleck

Last Published

July 2nd, 2020

Functions in smartmap (0.1.1)

smartmap-package

smartmap: Smartly Create Maps from R Objects
st_as_sfc

Convert coordinate matrices to sfc objects
smap

View spatial objects as interactive leaflet maps
smart_as_sf

Smartly convert an object to a simple features data frame
st_as_sf

Convert coordinate matrices to sf objects
as_coord_matrix

Coerce an R object to a matrix of coordinates