queryUSGSTileIndex: USGS Lidar Toolkit - Identify USGS Lidar Tiles Covering Area

View source: R/QueryFunctions.R

queryUSGSTileIndexR Documentation

USGS Lidar Toolkit – Identify USGS Lidar Tiles Covering Area

Description

Intersect a set of features (points or polygons) against a lidar tile index to determine which tiles are needed to provide coverage for the features. This involves both a spatial overlay operation and a database query. The database query is used to limit the features used for the spatial overlay. This dramatically increases the speed of the query when the area of interest only involves a few lidar projects.

Usage

queryUSGSTileIndex(
  x,
  y,
  buffer = 0,
  projectID = NULL,
  fieldname = "workunit_id",
  shape = "square",
  aoi = NULL,
  crs = "",
  index = "",
  segments = 60,
  return = "index",
  returnType = "sf",
  returncrs = "same",
  verbose = FALSE,
  useLegacyBuffering = FALSE,
  ...
)

Arguments

x

Location easting for the center of the area-of-interest.

y

Location northing for the center of the area-of-interest.

buffer

Distance in meters added or subtracted to (x,y) to create the area-of-interest. Can be 0 when used with (x,y) to return items providing coverage for point location(s). Can be a vector of values corresponding to the number of objects in aoi allowing a different buffer size for each object when aoi is a Spatial* or sf object. buffer can be negative with polygon features to reduce the area considered. However, you may end up with weird shapes if the distance is larger than the width of the polygon. Data in (x,y) and aoi are projected into the web mercator coordinate reference system before the buffer operation is done so the units for buffer are always meters.

projectID

Character string or list of character strings containing the ID(s) for the lidar project(s). Typically obtained by calling queryUSGSProjectIndex(). You must provide at least one project identifier.

fieldname

Character string containing the name of the field with matches for the projectID to be used when querying the tile index.

shape

Character string describing the shape of the sample area in the case of point features or the shape applied to the buffer corners when using polygon features. Valid values are "square" or "circle".

aoi

Spatial* or sf object containing a point or polygon describing the area of interest. Can be points or polygons.

crs

Valid proj4string string defining the coordinate reference system of (x,y). crs is required when using (x,y). crs is ignored when aoi is specified. crs can also be an EPSG code (numeric).

index

Index file for USGS lidar tiles If not provided, an index previously specified by a call to fetchUSGSProjectIndex or setUSGSProjectIndex will be used. If not provided and you have not called fetchUSGSTileIndex or setUSGSTileIndex, the function displays a warning and returns.

segments

Number of segments to use when generating a circular area of interest. When using a SpatialPoint* or sf object with shape = "circle", set segments to a rather large value (60 or higher) that is a multiple of 4. The st_buffer function from sf is used to build the sample areas and it accepts the number of segments in a quarter circle so small values for segments may not produce good circles. Values for segments that are not a multiple of 4 will not produce circles with the correct number of segments.

return

Character string specifying the kind of shapes to be returned. Valid values are ""aoi" to return shapes for each object in the aoi or the object defined by (x,y) and buffer with additional attributes providing lidar project information and "index" (default) to return tile shapes that provide coverage for the features in the "aoi" or the area defined by (x,y) and buffer. When tile shapes are returned there is no "aoi" information included with the project shape attributes.

returnType

Character string specifying the object type for the returned polygon object when (x,y) is used to specify the area-of-interest. Valid values are "Spatial" or "sf". returnType is ignored when aoi is specified.

returncrs

Valid proj4string string defining the coordinate reference system of the returned SpatialPolygonsDataFrame or sf object. A value of "same" will project the return object to the same coordinate reference system as aoi or to crs when used with (x,y).

verbose

Boolean to enable printing of status messages. This is really only useful for code debugging.

useLegacyBuffering

Boolean flag indicating that the buffer should be applied to features in their original projection. This was the original behavior of prepareTargetData prior to changes in June 2023. When TRUE, the old version of prepareTargetData is used. When TRUE, the new version of prepareTargetData is used. When writing new code, you will get more accurate features using the new version of prepareTargetData because features are first projected to UTM and then buffers are generated. The old version of prepareTargetData applied buffers using the features in their native projection so if you were using a projection that did not preserve distances or areas, buffered shapes (e.g., points with a circular buffer) did not represent the correct area.

...

Additional arguments passed to download.file

Details

Query the tile index to find tiles that intersect the buffered (x,y) point(s) or buffered feature(s) provided in aoi.

Value

A SpatialPolygonsDataFrame or sf object containing polygon(s) and attribute(s) for tiles covering the specified area. Attributes for the aoi are placed first in the data.frame followed by attributes for the lidar tile polygons..

Examples

## Not run: 
queryUSGSTileIndex(-13540901, 5806426, 180, shape = "circle", crs = 3857)
  
## End(Not run)

bmcgaughey1/USGSlidar documentation built on June 23, 2024, 1:25 a.m.