Skip to content

Instantly share code, notes, and snippets.

@fawda123
Last active May 11, 2018 20:05
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 fawda123/1870bb6f093b86139addcc515503a39e to your computer and use it in GitHub Desktop.
Save fawda123/1870bb6f093b86139addcc515503a39e to your computer and use it in GitHub Desktop.
plotlymapviewex
# load packages
library(sf)
library(plotly)
library(mapview)
# download data and save in memory
wsa <- read.csv("https://www.epa.gov/sites/production/files/2014-10/wsa_siteinfo_ts_final.csv")
# make an sf object
wsa <- st_as_sf(wsa, coords = c("LON_DD", "LAT_DD"), crs = 4269,agr = "constant")
# plotly scatterplot
plot_ly(wsa, x = ~XELEV, y = ~WSAREA) %>%
add_markers()
# plotly using ggplotly
p <- ggplot(wsa, aes(x = XELEV, y = WSAREA)) +
geom_point()
ggplotly(p)
# use mapview
mapview(wsa, zcol = 'XELEV')
mapview(wsa, zcol = 'WSAREA')
mapview(wsa, zcol = 'ECOWSA9')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment