Mapping and geoprocessing with R
R has an incredible number of spatial packages to enable a wide range of spatial tasks. End-to-end spatial analysis can now be done within R including creating and editing spatial data, geoprocessing, spatial statistics and the creation of elegant and interactive maps. But conducting spatial analysis in R is challenging for a variety of reasons including dealing with projections, making sense of spatial classes in R and knowing which of the many spatial packages can be used to perform the analyses you need. This workshop provides detailed coverage of the spatial-related topics you’ll need to conduct spatial analysis entirely within R.
- Initial coverage of packages dplyr and ggplot2 (not specifically spatial, but useful in the workshop)
- Getting spatial data (packages covered include maps, tigris, choroplethr, osmar, UScensus 2010, acs)
- Import/Export of spatial data (focus on rgdal and raster)
- Anatomy of spatial files and classes (focus on classes in sp and raster including SpatialPoints, SpatialPolygons, RasterLayer, RasterBrick)
- Coordinate reference systems (like it or not, it’s critically important to understand CRS when working with spatial data in R)
- Working with spatial objects (basic object information, extracting slot information, using rgeos functions to extract geographic detail, appending, merging)
- Static mapping (sp, ggplot2, ggmap, tmap)
- Interactive mapping (leaflet)
- Calculating distance (rgeos, geosphere)
- Geoprocessing (buffer, intersect, etc, packages rgeos, raster)
- Point pattern statistics (spatstat package, compare points to spatially random, computing density, quadrat counts)
- Interpolation and geostatistics (inverse distance weighting, kernel density and, my favorite, kriging)
ggplot2 package and faceting to create map panels:
ggplot(shp_df, aes(long, lat))+ geom_polygon(aes(group=group, fill=BoroName), show_guide = FALSE)+ facet_wrap(~BoroName, scale = "free")+ theme(axis.text = element_blank(),axis.ticks = element_blank())
Analyze and plot raster data with the
rastBrick = brick("manhattan.tif") plotRGB(rastBrick)
Create interactive maps using the
# Mount Everest leaflet() %>% addProviderTiles("OpenTopoMap") %>% setView( 86.92, 27.99, zoom=8)
Conduct spatial analysis (in this case variography and kriging) with
v = variogram(annualavg_pm25~1, air, cutoff=50000, cressie=TRUE) v.fit = fit.variogram(v, vgm(2, "Sph", 20000, 1)) kr = krige(annualavg_pm25~1, air, pred_locs, model=v.fit)
Zev Ross is president of ZevRoss Spatial Analysis, a company focused on data science, statistics and data visualization. He is an RStudio recommended trainer and consultant and has used R on a daily basis for nearly 15 years conducting data analysis and statistics for a wide range of clients including some of the world’s largest public health agencies and Fortune 500 companies. Zev has authored or co-authored more than 40 scientific research papers and maintains a popular data science blog.
Zev has been teaching R workshops for 7 years and clients include the New York City Department of Health, Freddie Mac, Zurich Insurance, UCLA, Columbia University, Agriculture Canada and many others. These on-site workshops have earned an average of 4.6 stars out of 5 in hundreds of anonymous reviews and 99% of the reviewers gave the workshops 4 or 5 stars.
The workshop involves a mix of slides, collaborative hands-on material and exercises and can be held at your institution. Participants use their own laptops and will be provided access to RStudio Server for the course. To fit with busy schedules the workshop can be held on weekdays or weekends. The workshop is designed for up to 15 participants (but let us know if you have a small or large group).