knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(overedge) library(ggplot2)
location <- get_location( type = "neighborhoods", name = "Downtown", package = "mapbaltimore" ) basemap <- ggplot() + layer_location_data( data = "streets", package = "mapbaltimore", location = location, color = "gray80" )
A large number of cities have adopted ArcGIS Hub as an open data platform for spatial and non-spatial data. get_esri_data wraps the esri2sf package to facilitate getting spatial data by bounding box or by area name.
For example, this FeatureServer from Open Baltimore provides a list of designated landmarks in Downtown Baltimore.
# https://data.baltimorecity.gov/datasets/landmarks-1/explore url <- "https://opendata.baltimorecity.gov/egis/rest/services/Hosted/Landmarks/FeatureServer/0" landmarks <- get_esri_data( location = location, url = url ) landmarks <- dplyr::select(landmarks, fid, name, address) basemap + layer_location_data( data = landmarks ) + layer_location_data( data = landmarks, geom = "text_repel", size = 2 ) + layer_neatline( data = location )
Even non-spatial Tables can be filtered to a location if the table includes latitude and longitude columns.
To get data from Open Street Map, you may need to refer to the OSM Wiki for more information about keys and tags such as tourism and artwork.
osm_artwork <- get_osm_data( location = location, key = "tourism", value = "artwork", geometry = "point" ) basemap + layer_location_data( data = osm_artwork, aes(color = material) ) + layer_neatline( data = location, expand = TRUE ) + theme_legend(position = "topleft")
The get_flickr_photos function depends on a development version of the FlickrAPI package so I am not currently able to render the vignette to show how it works.
photos_sf <- get_flickr_photos( location = location, img_size = "s", tags = "monument", orientation = "landscape", geometry = TRUE # this is the default )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.