Skip to content

crazycapivara/cartovl

Repository files navigation

An R Interface to carto-vl

Travis build status Project Status: Active – The project has reached a stable, usable state and is being actively developed.

Cartovl for R makes carto-vl, an open source JavaScript library to create vector-based visualizations on top of mapbox-gl, available within R via the htmlwidgets package.

Notes

  • The package development is in an early state.
  • Please check the examples as a starting point.

Installation

You can install the latest version of cartovl from github with:

# install.packages("devtools")
devtools::install_github("crazycapivara/cartovl")

Example

library(sf)
library(geojsonio)
library(cartovl)

nc_geojson <- system.file("shape/nc.shp", package = "sf") %>%
  st_read() %>%
  geojson_json()

viz_def <- list(
  "color: ramp($AREA, [midnightblue, gold])"
)

map <- cartovl() %>%
  set_view(-79.89042, 35.23582, 6) %>%
  add_layer(nc_geojson, viz_def)

if (interactive()) map