Skip to content

Instantly share code, notes, and snippets.

@jebyrnes
Created January 2, 2018 18:53
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jebyrnes/80f28e754c51bfdcef958a9684e19692 to your computer and use it in GitHub Desktop.
A brief visualization
library(tidyverse)
library(broom)
library(sp)
library(spdplyr)
library(ggplot2)
library(ggmap)
library(rgdal)
library(raster)
#read in spatialPolygonsDataFrame (shapefile)
#classifications <- readOGR("../agu_data/ff_polys_proj.sqlite", "ff_consensus", stringsAsFactors=FALSE)
classifications <- readRDS("../agu_data/ff_polys_proj.rds")
###quick visualization of Monterey
#make a data frame for use by ggplot2
mont_df <- crop(classifications, extent(-122.0, -121.85, 36.5, 36.65)) %>%
filter(threshold==6) %>% tidy
#get a background map from google
mont_map <- get_map(c(-122.0, 36.5, -121.85, 36.65), zoom=12)
#make a jpeg
jpeg("./mont_example.jpg")
ggmap(mont_map) +
geom_polygon(data = mont_df,
mapping=aes(x=long, y=lat, group=group),
fill="darkgreen") +
xlab("") + ylab("") + theme_void()
dev.off()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment