download_DEM: Downloading DEM data from USGS servers

View source: R/DEPRECATED.R

download_DEMR Documentation

Downloading DEM data from USGS servers

Description

This function downloads and rescales the median statistic of the Global Multi-resolution Terrain Elevation Data (GMTED2010) data from the servers of the U.S. Geological Survey (USGS) available at https://topotools.cr.usgs.gov/gmted_viewer/gmted2010_global_grids.php. The data is downloaded at 30 arc-sec latitude/longitude grid cells and subsequently resampled to match Train_ras and Target_res. This data is the default for kriging within this package.

Usage

download_DEM(
  Train_ras = NULL,
  Target_res = NULL,
  Shape = NULL,
  Buffer = 0.5,
  ID = "ID",
  Dir = getwd(),
  Keep_Temporary = FALSE,
  Source = "USGS"
)

Arguments

Train_ras

A raster file containing the data which is to be downscaled. GMTED2010 data is then resampled to match this.

Target_res

The target resolution for the kriging step (i.e. wich resolution to downscale to). An object as specified/produced by raster::res() or a single number (GMTED2010 data will be aggregated) or a raster which the data should be comparable to after kriging (GMTED2010 data will be resampled).

Shape

Optional, a SpatialPolygonsDataFrame or data.frame object. If Shape is a SpatialPolygonsDataFrame, this will be treated as a shapefile and the output will be cropped and masked to this shapefile. If Shape is a data.frame of geo-referenced point records, it needs to contain Lat and Lon columns as well as a non-repeating ID-column.

Buffer

Optional. Identifies how big a rectangular buffer to draw around points if Shape is a data frame of points. Buffer is expressed as centessimal degrees.

ID

Optional. Identifies which column in Shape to use for creation of individual buffers if Shape is a data.frame.

Dir

Directory specifying where to download data to.

Keep_Temporary

Logical, whether to delete individual, global, 30 arc-sec files or keep them to be reused in later analyses.

Source

Character. Whether to attempt download from the official USGS data viewer (Source = "USGS") or a static copy of the data set on a private drive (Source = "Drive"). Default is "USGS". Use this if the USGS viewer is unavailable.

Value

A list containing two raster object ready to be used as covariates for kriging, and two NETCDF (.nc) files in the specified directory.

Examples

## Not run: 
# Downloading ERA5-Land air temperature reanalysis data in 12-hour intervals for 02/01/1995 - 04/01/1995 (DD/MM/YYYY). API User and Key in this example are non-functional. Substitute with your user number and key to run this example.
Extent <- extent(c(11.8,15.1,50.1,51.7)) # roughly the extent of Saxony
API_User <- "..."
API_Key <- "..."
State_Raw <- download_ERA(
Variable = "2m_temperature",
DataSet = "era5-land",
DateStart = "1995-01-02",
DateStop = "1995-01-04",
TResolution = "hour",
TStep = 12,
Extent = Extent,
API_User = API_User,
API_Key = API_Key
)
State_Raw # a raster brick with 6 layers at resolution of ~0.1°
# Downloading GMTED2010-data at resolution and extent obtained by a call to download_ERA and a target resolution of .02.
Covs_ls <- download_DEM(
Train_ras = State_Raw,
Target_res = .02,
Keep_Temporary = TRUE
)
Covs_ls # a list with two elements: (1) GMTED 2010 data at training resolution, and (2) GMTED 2010 data aggregated as close as possible to a resolution of 0.02

## End(Not run)


ErikKusch/KrigR documentation built on Feb. 17, 2025, 2:09 p.m.