Friday, May 3, 2013

RG#106: add satellite imagery, or open street maps to your plots using openmap package (bing, mapquest)


library(OpenStreetMap)
library(rgdal)

# get world map
map <- openmap(c(70,-179), c(-70,179))
plot(map)

bingmap <- openmap(c(70,-179), c(-70,179), type = "bing")
plot(bingmap)


# types available 

# type = c("osm", "osm-bw", "maptoolkit-topo", "waze", "mapquest", "mapquest-aerial", "bing", "stamen-toner", "stamen-terrain", "stamen-watercolor", "osm-german", "osm-wanderreitkarte", "mapbox", "esri", "esri-topo", "nps", "apple-iphoto", "skobbler", "cloudmade-<id>", "hillshade", "opencyclemap", "osm-transport", "osm-public-transport", "osm-bbike", "osm-bbike-german")


#zoom maps, plot a portion
upperLeft, lowerRight
lat <- c(43.834526782236814, 30.334953881988564)
lon <- c(-85.8857421875, -70.0888671875)
southest <- openmap(c(lat[1],lon[1]),c(lat[2],lon[2]),zoom=7,'osm')
plot(southest) 




library(UScensus2000tract)
data(south_carolina.tract)
lat <- c(35.834526782236814, 30.334953881988564)
lon <- c(-85.8857421875, -70.0888671875)
southest <- openmap(c(lat[1],lon[1]),c(lat[2],lon[2]),zoom=7,'osm')
south_carolina.tract <- spTransform(south_carolina.tract,osm())

plot(southest)
plot(south_carolina.tract,add=TRUE,col=(south_carolina.tract@data$med.age>35)+4)


plot(southest)
plot(south_carolina.tract,add=TRUE,col=(south_carolina.tract@data$med.age>55)+4)






No comments:

Post a Comment

Note: Only a member of this blog may post a comment.