Smartly Create Maps from R Objects

Preview spatial data as 'leaflet' maps with minimal effort. smartmap is optimized for interactive use and distinguishes itself from similar packages because it does not need real spatial ('sp' or 'sf') objects an input; instead, it tries to automatically coerce everything that looks like spatial data to sf objects or leaflet maps. It - for example - supports direct mapping of: a vector containing a single coordinate pair, a two column matrix, a data.frame with longitude and latitude columns, or the path or URL to a (possibly compressed) 'shapefile'.


smartmap

smartmap is an R package for previewing spatial data as leaflet maps. It is designed for interactive use and produces nice maps with minimal typing 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 package homepage for more infos.

Installation

You can install smartmap from CRAN:

install.packages("smartmap")

or get the development version from GitHub with:

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

Development status

smartmap is in maintenance mode since I don’t much work with spatial data anymore, so new features are unlikely to be added.

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
# Note: the naturalearthdata url doesn't work anymore and i didn't find another good new example
# 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)

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("smartmap")

0.2.0 by Stefan Fleck, 9 months ago


https://github.com/s-fleck/smartmap


Report a bug at https://github.com/s-fleck/smartmap/issues


Browse source code at https://github.com/cran/smartmap


Authors: Stefan Fleck [aut, cre] (ORCID:


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports leaflet, magrittr, sf, utils

Suggests knitr, covr, testthat, leafsync, rmarkdown


See at CRAN