createSampleAreas: USGS Lidar Toolkit - Create sample areas that include a...

View source: R/UtilityFunctions.R

createSampleAreasR Documentation

USGS Lidar Toolkit – Create sample areas that include a smaller target area.

Description

Create sample polygons to help obfuscate a sensitive location when requesting data from non-secure sources. The basic idea is to create a square or circular area that can be use to request data. The desired target location (and area) will be contained within the sample area but not centered on the sample area.

Usage

createSampleAreas(
  buffer = 0,
  sizeMultiplier = 0,
  shape = "square",
  aoi = "",
  minOffsetProportion = 0.1,
  segments = 60
)

Arguments

buffer

Distance or list of distances added to the maximum bounding box dimension for aoi to create the sample area polygon(s). Can be 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. All values for buffer must be larger than 0. Can not be specified with sizeMultiplier.

sizeMultiplier

Multiplier applied to the maximum bounding box dimensions for each aoi object to compute the size of the sample area polygon. Can not be specified with buffer.

shape

Character string describing the shape of the sample area. Valid values are "square" or "circle".

aoi

Spatial* or sf object containing a point(s) or polygon(s) describing the target area(s) of interest. Can be points or polygons. Usually this is a set of polygons representing the actual area for which you want data. For best results, aoi should contain square or circular polygons. Sample areas generated for irregular polygonal target areas may not fully contain the target area polygon.

minOffsetProportion

Proportion of buffer that will be used as the minimum offset between the target location and the center of the sample polygon. Setting minOffsetProportion=0 will allow some sample polygons to have the same location (centroid) as the target location.

segments

Number of segments to use when generating a circular sample areas. 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.

Details

Create polygons that can be used when requesting data from non-secure sources that contain the specific target location. Polygons are randomly offset from the target area centroid so there is no consistent relationship between the location of the polygon and the target area.

Units for buffer are the same as the horizontal units for the input features so you shouldn't use data in LON-LAT with units of degrees.

Value

A set sample area polygons. The return type will be the same as the aoi type.

Examples

pt1 <- sf::st_point(c(-13540901, 5806426 + 500))
pt2 <- sf::st_point(c(-13540901 + 500, 5806426 - 500))
pt3 <- sf::st_point(c(-13540901 - 500, 5806426))
pt4 <- sf::st_point(c(-13540901 + 1000, 5806426 - 1000))
id <- c("P1", "P2", "P3", "P4")
x_sf <- sf::st_sf(data.frame(ID = id, stringsAsFactors = FALSE),
  geom = sf::st_sfc(pt1, pt2, pt3, pt4),
  crs = 3857)
  pt_aoi <- prepareTargetData(aoi = x_sf, buffer = 75, shape = "circle")
sample_areas <- createSampleAreas(aoi = pt_aoi, buffer = 500)

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