FedData is an R package implementing functions to automate downloading geospatial data available from several federated data sources (mainly sources maintained by the US Federal government).
FedData version 2.5 will be the final minor CRAN release of FedData 2. FedData 3 will be released in the coming months, but some code built on FedData 2 will not be compatible with FedData 3.
Currently, the package enables extraction from seven datasets:
This package is designed with the large-scale geographic information system (GIS) use-case in mind: cases where the use of dynamic web-services is impractical due to the scale (spatial and/or temporal) of analysis. It functions primarily as a means of downloading tiled or otherwise spatially-defined datasets; additionally, it can preprocess those datasets by extracting data within an area of interest (AoI), defined spatially. It relies heavily on the sp, raster, and rgdal packages.
This package has been built and tested on a source (Homebrew) install of R on macOS 10.13 (High Sierra), and has been successfully run on Ubuntu 14.04.5 LTS (Trusty), Ubuntu 16.04.1 LTS (Xenial) and binary installs of R on Mac OS 10.13 and Windows 10.
Development version from GitHub:
Linux (Ubuntu 14.04.5 or 16.04.1):
First, in terminal:
bash sudo add-apt-repository ppa:ubuntugis/ppa -y sudo apt-get update -q sudo apt-get install libssl-dev libcurl4-openssl-dev netcdf-bin libnetcdf-dev gdal-bin libgdal-dev Then, in R:
This demonstration script is available as an R Markdown document in the GitHub repository: https://github.com/ropensci/FedData.
# Get the daily GHCN data (GLOBAL) # Returns a list: the first element is the spatial locations of stations, # and the second is a list of the stations and their daily data GHCN.prcp <- get_ghcn_daily(template = vepPolygon, label = "VEPIIN", elements = c('prcp')) # Plot the NED again raster::plot(NED) # Plot the spatial locations sp::plot(GHCN.prcp$spatial, pch = 1, add = TRUE) legend('bottomleft', pch = 1, legend="GHCN Precipitation Records")
# Elements for which you require the same data # (i.e., minimum and maximum temperature for the same days) # can be standardized using standardize==T GHCN.temp <- get_ghcn_daily(template = vepPolygon, label = "VEPIIN", elements = c('tmin','tmax'), years = 1980:1985, standardize = TRUE) # Plot the NED again raster::plot(NED) # Plot the spatial locations sp::plot(GHCN.temp$spatial, add = TRUE, pch = 1) legend('bottomleft', pch = 1, legend = "GHCN Temperature Records")
# Get the NRCS SSURGO data (USA ONLY) SSURGO.VEPIIN <- get_ssurgo(template = vepPolygon, label = "VEPIIN") #> Warning in rbind(names(probs), probs_f): number of columns of result is not #> a multiple of vector length (arg 2) #> Warning: 1 parsing failure. #> row # A tibble: 1 x 5 col row col expected actual file expected <int> <chr> <chr> <chr> <chr> actual 1 1277 slope.r no trailing characters .5 '/Users/bocinsky/git/FedDat… file # A tibble: 1 x 5 # Plot the NED again raster::plot(NED) # Plot the SSURGO mapunit polygons plot(SSURGO.VEPIIN$spatial, lwd = 0.1, add = TRUE)
# Or, download by Soil Survey Area names SSURGO.areas <- get_ssurgo(template = c("CO670","CO075"), label = "CO_TEST") # Let's just look at spatial data for CO675 SSURGO.areas.CO675 <- SSURGO.areas$spatial[SSURGO.areas$spatial$AREASYMBOL=="CO075",] # And get the NED data under them for pretty plotting NED.CO675 <- get_ned(template = SSURGO.areas.CO675, label = "SSURGO_CO675") # Plot the SSURGO mapunit polygons, but only for CO675 plot(NED.CO675) plot(SSURGO.areas.CO675, lwd = 0.1, add = TRUE)