Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Shapefiles in R
# load up area shape file:
library(maptools)
area <- readShapePoly("ne_10m_parks_and_protected_lands_area.shp")
# # or file.choose:
# area <- readShapePoly(file.choose())
library(RColorBrewer)
colors <- brewer.pal(9, "BuGn")
library(ggmap)
mapImage <- get_map(location = c(lon = -118, lat = 37.5),
color = "color",
source = "osm",
# maptype = "terrain",
zoom = 6)
area.points <- fortify(area)
ggmap(mapImage) +
geom_polygon(aes(x = long,
y = lat,
group = group),
data = area.points,
color = colors[9],
fill = colors[6],
alpha = 0.5) +
labs(x = "Longitude",
y = "Latitude")
@areeves87

This comment has been minimized.

Show comment
Hide comment
@areeves87

areeves87 Nov 27, 2017

I had trouble downloading from source = "osm". After switching the source to "google", the download went smoothly.

Nice work! Thanks for the code.

I had trouble downloading from source = "osm". After switching the source to "google", the download went smoothly.

Nice work! Thanks for the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment