Skip to content

Instantly share code, notes, and snippets.

@gregmacfarlane
Created June 2, 2017 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gregmacfarlane/3c77b6f7748d8f140defa26e5b10f403 to your computer and use it in GitHub Desktop.
Save gregmacfarlane/3c77b6f7748d8f140defa26e5b10f403 to your computer and use it in GitHub Desktop.
Demo shiny Rmd with topojson file
---
title: "Test RMD"
output: html_document
runtime: shiny
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(leaflet)
library(shiny)
library(geojsonio)
library(sp)
```
## GeoJSON
```{r geo}
us <- geojsonio::geojson_read("http://eric.clst.org/wupl/Stuff/gz_2010_us_040_00_500k.json", what = "sp")
leaflet(us) %>% addTiles() %>% addPolygons()
```
## TopoJSON
```{r topo}
eu <- geojsonio::geojson_read("https://raw.githubusercontent.com/Leaflet/Leaflet.VectorGrid/master/docs/eu-countries.topo.json", what = "sp")
leaflet(eu) %>% addTiles() %>% addPolygons()
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment