FedData v2.5.6

0

Monthly downloads

0th

Percentile

Functions to Automate Downloading Geospatial Data Available from Several Federated Data Sources

Functions to automate downloading geospatial data available from several federated data sources (mainly sources maintained by the US Federal government). Currently, the package enables extraction from seven datasets: The National Elevation Dataset digital elevation models (1 and 1/3 arc-second; USGS); The National Hydrography Dataset (USGS); The Soil Survey Geographic (SSURGO) database from the National Cooperative Soil Survey (NCSS), which is led by the Natural Resources Conservation Service (NRCS) under the USDA; the Global Historical Climatology Network (GHCN), coordinated by National Climatic Data Center at NOAA; the Daymet gridded estimates of daily weather parameters for North America, version 3, available from the Oak Ridge National Laboratory's Distributed Active Archive Center (DAAC); the International Tree Ring Data Bank; and the National Land Cover Database (NLCD).

Readme

cran
version CRAN downloads per
month CRAN
downloads Build
Status Zenodo
DOI ROpenSci
Status

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

Contributors

  • Dylan Beaudette - USDA-NRCS Soil Survey Office, Sonora, CA
  • Scott Chamberlain - ROpenSci and Museum of Paleontology at UC Berkeley

Install FedData

  • From CRAN:

    install.packages('FedData')
    
  • Development version from GitHub:

    install.packages("devtools")
    devtools::install_github("ropensci/FedData")
    
  • 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:

    update.packages("survival")
    install.packages("devtools")
    devtools::install_github("ropensci/FedData")
    

Demonstration

This demonstration script is available as an R Markdown document in the GitHub repository: https://github.com/ropensci/FedData.

Load FedData and define a study area

# FedData Tester
library(FedData)
library(magrittr)

# Extract data for the Village Ecodynamics Project "VEPIIN" study area:
# http://veparchaeology.org
vepPolygon <- polygon_from_extent(raster::extent(672800, 740000, 4102000, 4170000),
                                  proj4string = "+proj=utm +datum=NAD83 +zone=12")

Get and plot the National Elevation Dataset for the study area

# Get the NED (USA ONLY)
# Returns a raster
NED <- get_ned(template = vepPolygon,
               label = "VEPIIN")
# Plot with raster::plot
raster::plot(NED)

Get and plot the Daymet dataset for the study area

# Get the DAYMET (North America only)
# Returns a raster
DAYMET <- get_daymet(template = vepPolygon,
               label = "VEPIIN",
               elements = c("prcp","tmax"),
               years = 1980:1985)
# Plot with raster::plot
raster::plot(DAYMET$tmax$X1985.10.23)

Get and plot the daily GHCN precipitation data for the study area

# 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")

Get and plot the daily GHCN temperature data for the study area

# 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 and plot the National Hydrography Dataset for the study area

# Get the NHD (USA ONLY)
NHD <- get_nhd(template = vepPolygon, 
               label = "VEPIIN")
# Plot the NED again
raster::plot(NED)
# Plot the NHD data
NHD %>%
  lapply(sp::plot,
         col = 'black',
         add = TRUE)

Get and plot the NRCS SSURGO data for the study area

# 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)

Get and plot the NRCS SSURGO data for particular soil survey areas

# 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)

Get and plot the ITRDB chronology locations in the study area

# Get the ITRDB records
ITRDB <- get_itrdb(template = vepPolygon,
                        label = "VEPIIN",
                        makeSpatial = TRUE)
# Plot the NED again
raster::plot(NED)
# Map the locations of the tree ring chronologies
plot(ITRDB$metadata,
     pch = 1,
     add = TRUE)
legend('bottomleft',
       pch = 1,
       legend = "ITRDB chronologies")

Get and plot the National Land Cover Dataset for the study area

# Get the NLCD (USA ONLY)
# Returns a raster
NLCD <- get_nlcd(template = vepPolygon,
                 year = 2011,
                 dataset = "landcover",
                 label = "VEPIIN")
# Plot with raster::plot
raster::plot(NLCD)


# You can also download the Canopy or impervious datasets:
NLCD_canopy <- get_nlcd(template = vepPolygon,
                 year = 2011,
                 dataset = "canopy",
                 label = "VEPIIN")
# Plot with raster::plot
raster::plot(NLCD_canopy)


NLCD_impervious <- get_nlcd(template = vepPolygon,
                 year = 2011,
                 dataset = "impervious",
                 label = "VEPIIN")
# Plot with raster::plot
raster::plot(NLCD_impervious)


Acknowledgements

This package is a product of SKOPE (Synthesizing Knowledge of Past Environments) and the Village Ecodynamics Project. This software is licensed under the MIT license.

FedData was reviewed for rOpenSci by @jooolia, and was greatly improved as a result. rOpenSci onboarding was coordinated by @sckott.

Functions in FedData

Name Description
download_ssurgo_inventory Download a zipped directory containing a shapefile of the SSURGO study areas.
get_itrdb Download the latest version of the ITRDB, and extract given parameters.
get_ghcn_daily_station Download and extract the daily data for a GHCN weather station.
get_ned Download and crop the 1 (~30 meter) or 1/3 (~10 meter) arc-second National Elevation Dataset.
get_ned_tile Download and crop tile from the 1 (~30 meter) or 1/3 (~10 meter) arc-second National Elevation Dataset.
pkg_test Install and load a package.
polygon_from_extent Turn an extent object into a polygon
get_huc4 Download and crop a shapefile of the HUC4 regions of the National Hydrography Dataset.
download_huc4 Download a zipped directory containing a shapefile of the HUC4 subregions of the NHD.
download_ssurgo_study_area Download a zipped directory containing the spatial and tabular data for a SSURGO study area.
extract_ssurgo_data Extract data from a SSURGO database pertaining to a set of mapunits.
get_ghcn_inventory Download and crop the inventory of GHCN stations.
get_ssurgo Download and crop data from the NRCS SSURGO soils database.
get_ssurgo_inventory Download and crop a shapefile of the SSURGO study areas.
read_crn_metadata Read metadata from a Tucson-format chronology file.
sequential_duplicated Get a logical vector of which elements in a vector are sequentially duplicated.
get_ssurgo_study_area Download and crop the spatial and tabular data for a SSURGO study area.
nlcd_canopy_pam The NLCD canopy PAM attributes.
get_daymet_tile Download and crop a netcdf tile from the 1-km DAYMET daily weather dataset.
spdf_from_polygon Turn a SpatialPolygons object into a SpatialPolygonsDataFrame.
station_to_data_frame Convert a list of station data to a single data frame.
get_ghcn_daily Download and crop the Global Historical Climate Network-Daily data.
get_daymet Download and crop the 1-km DAYMET daily weather dataset.
nlcd_impervious_pam The NLCD impervious PAM attributes.
get_nlcd Download and crop the National Land Cover Database.
nlcd_landcover_pam The NLCD landcover PAM attributes.
substr_right Get the rightmost 'n' characters of a character string.
get_nhd Download and crop the National Hydrography Dataset.
get_nlcd_tile Download and crop a tile from the National Land Cover Database.
nlcd_tiles The NLCD tiles SpatialPolygonsDataFrame.
pal_nlcd NLCD colour map palettes
unwrap_rows Unwraps a matrix and only keep the first n elements.
get_nhd_subregion Download and crop data from a zipped HUC4 subregion of the National Hydrography Dataset.
read_crn Read a Tucson-format chronology file.
read_crn_data Read chronology data from a Tucson-format chronology file.
SDA_query Submit a Soil Data Access (SDA) Query
download_itrdb Download the latest version of the ITRDB.
download_nlcd_tile Download a zipped tile from the National Land Cover Database.
download_nhd_subregion Download a zipped NHD HUC4 subregion.
daymet_tiles The DAYMET tiles SpatialPolygonsDataFrame.
download_data Use curl to download a file.
download_daymet_tile Download a netcdf tile from the 1-km DAYMET daily weather dataset.
download_ned_tile Download a zipped tile from the 1 (~30 meter) or 1/3 (~10 meter) arc-second National Elevation Dataset.
download_ghcn_daily_station Download the daily data for a GHCN weather station.
No Results!

Last month downloads

Details

Type Package
Date 2019-01-11
URL https://github.com/ropensci/FedData
BugReports https://github.com/ropensci/FedData/issues
License MIT + file LICENSE
Repository CRAN
NeedsCompilation no
RoxygenNote 6.1.1
LazyData true
Encoding UTF-8
Packaged 2019-01-11 17:33:59 UTC; bocinsky
Date/Publication 2019-01-11 17:50:03 UTC

Include our badge in your README

[![Rdoc](http://www.rdocumentation.org/badges/version/FedData)](http://www.rdocumentation.org/packages/FedData)