Created
August 7, 2013 19:28
-
-
Save mjrich/6177620 to your computer and use it in GitHub Desktop.
R (markdown) code to overlay lat/longs on a static map with OSM base.
This file contains 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
library("ggmap") | |
library("mapproj") | |
### Tunisia Map | |
``` {r Map, dpi=100,echo=FALSE, message=FALSE, comment=NA, fig.width=6} | |
# get map image from google | |
map <- get_map(location = c(lon = 9.489765, lat = 35.584840), source = "osm", zoom = 6) | |
# start a ggplot. it won't plot til we type p | |
p <- ggmap(map) | |
# add points last so they are on top | |
p <- p + geom_point(data=data,aes(x=lon, y=lat),colour="red",size=4, na.rm = TRUE) + theme ( | |
panel.grid.major = element_blank (), # remove major grid | |
panel.grid.minor = element_blank (), # remove minor grid | |
axis.text = element_blank (), | |
axis.title = element_blank (), | |
axis.ticks = element_blank () | |
) | |
# display plot | |
p | |
#HT http://stackoverflow.com/questions/14095495/ploting-coordinates-of-multiple-points-at-google-map-in-r | |
``` | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment