Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/crazycapivara/openlayers

An R Interface to OpenLayers
https://github.com/crazycapivara/openlayers

Last synced: 3 months ago
JSON representation

An R Interface to OpenLayers

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, echo = FALSE}
library(covr)
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```

# An R Interface to OpenLayers

[![Travis-CI Build Status](https://travis-ci.org/crazycapivara/openlayers.svg?branch=master)](https://travis-ci.org/crazycapivara/openlayers) [![Travis-CI Build Status](https://travis-ci.org/crazycapivara/openlayers.svg?branch=develop)](https://travis-ci.org/crazycapivara/openlayers)

[OpenLayers](https://openlayers.org/) is an open-source JavaScript library _making it easy to put a dynamic map in any web page_. The goal of the openlayers R package is to make this functionality available within R via the [htmlwidgets](https://github.com/ramnathv/htmlwidgets) package. Check [NEWS](NEWS.md) file for available functionality.

## Installation

You can install openlayers from github with:

```{r gh-installation, eval = FALSE}
# install.packages("devtools")
devtools::install_github("crazycapivara/openlayers")

# latest version
devtools::install_github("crazycapivara/openlayers", ref = "develop")
```

## Examples

Here we go with some basic examples:

```{r loading, eval = TRUE}
library(openlayers)
```

```{r example, eval = FALSE}
ol() %>%
add_stamen_tiles() %>%
set_view(9.5, 51.31667, zoom = 10)

## Points
library("geojsonio")

cities <- us_cities[1:5, ]

ol() %>%
add_stamen_tiles() %>%
add_features(cities, style = icon_style(),
popup = cities$name)

## Polygons
library("sf")

nc <- st_read(system.file("gpkg/nc.gpkg", package = "sf"),
quiet = TRUE)

ol() %>%
add_stamen_tiles("watercolor") %>%
add_stamen_tiles(
"terrain-labels",
options = layer_options(max_resolution = 13000)
) %>%
add_features(
data = nc,
style = fill_style("yellow") + stroke_style("blue", 1),
popup = nc$AREA
) %>%
add_overview_map()
```

## Documentation

A detailed documentation of the package is still under development, but all functions are documented, so that you can use the build in help functionality of R. Furthermore, check the example scripts in [inst/examples/](https://github.com/crazycapivara/openlayers/blob/master/inst/examples) to get an idea about how to use this package.

## Code coverage

```{r code-coverage, eval = TRUE}
package_coverage()
```