Created
February 17, 2013 03:19
-
-
Save mollietaylor/4969941 to your computer and use it in GitHub Desktop.
Shapefiles in R
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I had trouble downloading from source = "osm". After switching the source to "google", the download went smoothly.
Nice work! Thanks for the code.