1 / 16

Quick maps in R

Quick maps in R. Melanie Frazier, NCEAS. Presentation materials here: http://nceas.ucsb.edu/~frazier/RSpatialGuides/ggmap/. Have Lat/Long data?. And, you want to see where they are. Data from the EPA’s WestuRe project: http://www.epa.gov/wed/pages/models/WestuRe/WestuRe.htm.

chakra
Download Presentation

Quick maps in R

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Quick maps in R Melanie Frazier, NCEAS Presentation materials here: http://nceas.ucsb.edu/~frazier/RSpatialGuides/ggmap/

  2. Have Lat/Long data? And, you want to see where they are Data from the EPA’s WestuRe project: http://www.epa.gov/wed/pages/models/WestuRe/WestuRe.htm

  3. Many options: But we’ll stick with 2 library(plotKML) library(ggmap)

  4. ggmap Part 1 Download the map raster Part 2 Overlay data onto raster Refer to Quickstart guide:

  5. ggmap: Part 1 (getting the map) Specify coordinates - geocode myLocation <- “University of Washington” - Lat/Long myLocation <- c(lon=-95.36, lat=29.76) - Bounding box (lowerleftlon, lowerleftlat, upperrightlon, upperrightlat) myLocation <- c(-130, 30, -105, 50) [NOTE: glitchy for google maps]

  6. ggmap: Part 1 (getting the map) B. Define map source, maptype, and color maptype = watercolor toner terrain source stamen terrain satellite roadmap hybrid google color can do any of the maps in “bw” osm (and, cloudmade)

  7. ggmap: Part 1 (getting the map) B. Define map source, maptype, and color Scale matters in regard to map source/type

  8. ggmap: Part 1 (getting the map) B. get_mapfunction provides a general approach for quickly getting maps myMap <- get_map(location = myLocation, source = “stamen”, maptype = “watercolor”, color = “bw”) Additional options such as “zoom” and “crop” ?ggmap

  9. ggmap: Part 1 (getting the map) Sometimes get_map doesn’t provide the control needed to get the map you want. In this case, use the specific functions designed for the different map sources: get_googlemap get_openstreetmap get_stamenmap get_cloudmademap

  10. ggmap: Part 2 (overlaying your data) A. Plot the raster ggmap(myMap) B. Get your lat/long point data: myData <- read.csv(“http://nceas.ucsb.edu/~frazier/RSpatialGuides/ggmap/EstuaryData.csv”) C. Add points (ggplot2 syntax) ggmap(myMap)+ geom_point(aes(x=estLongitude, y=estLatitude), data=myData, alpha=0.5, color=“darkred”, size=3)

  11. ggmaps: Part 2

  12. ggmaps: Part 2

  13. ggmap: Additional options

  14. plotKML

  15. plotKML Tutorial: http://gsif.isric.org/doku.php?id=wiki:tutorial_plotkml Load libraries: library(plotKML) library(sp) Convert to spatial dataframe object: coordinates(myData) <- ~estLongitude+estLatitude Provide the projection (just copy this): proj4string(myData) <- CRS("+proj=longlat +datum=WGS84") Make the plot: plotKML(myData, colour="lnEstArea", balloon=TRUE)

  16. Questions Presentation materials here: http://nceas.ucsb.edu/~frazier/RSpatialGuides/ggmap/

More Related