Skip to content

Instantly share code, notes, and snippets.

@mollietaylor
Created February 17, 2013 03:19
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mollietaylor/4969941 to your computer and use it in GitHub Desktop.
Save mollietaylor/4969941 to your computer and use it in GitHub Desktop.
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
Copy link

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