Learn R Programming

elevatr (version 0.2.0)

get_elev_raster: Get Raster Elevation

Description

Several web services provide access to raster elevation. Currently, this function provides access to the Mapzen Terrain Service The function accepts a data.frame of x (long) and y (lat), an sp, or raster object as input. A raster object is returned.

Usage

get_elev_raster(locations, z, prj = NULL, src = c("aws"),
  expand = NULL, clip = c("tile", "bbox", "locations"),
  verbose = TRUE, ...)

Arguments

locations

Either a data.frame of x (long) and y (lat), an sp, or raster object as input.

z

The zoom level to return. The zoom ranges from 1 to 14. Resolution of the resultant raster is determined by the zoom and latitude. For details on zoom and resolution see the documentation from Mapzen at https://mapzen.com/documentation/terrain-tiles/data-sources/#what-is-the-ground-resolution

prj

A PROJ.4 string defining the projection of the locations argument. If a sp or raster object is provided, the PROJ.4 string will be taken from that. This argument is required for a data.frame of locations."

src

A character indicating which API to use, currently only "aws" is used.

expand

A numeric value of a distance, in map units, used to expand the bounding box that is used to fetch the terrain tiles. This can be used for features that fall close to the edge of a tile and additional area around the feature is desired. Default is NULL.

clip

A character value used to determine clipping of returned DEM. The default value is "tile" which returns the full tiles. Other options are "bbox" which returns the DEM clipped to the bounding box of the original locations (or expanded bounding box if used), or "locations" if the spatials data (e.g. polygons) in the input locations should be used to clip the DEM. Locations are not used to clip input point datasets. Instead the bounding box is used.

verbose

Toggles on and off the note about units and coordinate reference system.

...

Extra arguments to pass to httr::GET via a named vector, config. See get_aws_terrain for more details.

Value

Function returns a SpatialPointsDataFrame in the projection specified by the prj argument.

Details

Currently, the get_elev_raster utilizes only the Amazon Web Services (https://aws.amazon.com/public-datasets/terrain/) terrain tiles. Versions of elevatr 0.1.4 or earlier had options for the Mapzen terrain tiles. Mapzen data is no longer available. Support for the replacment Nextzen tiles is not currently available

The terrain data is provided via x, y, and z tiles (see http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames for details.) The x and y are determined from the bounding box of the object submitted for locations argument, and the z argument must be specified by the user.

Examples

Run this code
# NOT RUN {
loc_df <- data.frame(x = runif(6,min=sp::bbox(lake)[1,1], 
                               max=sp::bbox(lake)[1,2]),
                     y = runif(6,min=sp::bbox(lake)[2,1], 
                               max=sp::bbox(lake)[2,2]))
x <- get_elev_raster(locations = loc_df, prj = sp::proj4string(lake), z=10)

data(lake)
x <- get_elev_raster(lake, z = 12)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab