db_query_stratum_counts: Export point count rasters that intersect query features

Description Usage Arguments Value

View source: R/db_functions.R

Description

This function takes a set of features (points, lines, polygons or an extent in the form of a matrix or raster Extent object), identifies the raster tiles of point count data that the features intersect with, and exports these to a GeoTIFF file. Optionally, the data to export can be restricted to a specified time period. If any parts of the query area are covered by LiDAR data for two or more dates, the data to export is chosen based on the overlap.action and overlap.yearorder parameters.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
db_query_stratum_counts(
  dbsettings,
  geom,
  outpath,
  with.purpose = c("general", "postfire"),
  time.interval = NULL,
  default.epsg = NULL,
  overlap.action = c("latest", "earliest", "year", "fail"),
  overlap.yearorder = NULL
)

Arguments

dbsettings

A named list of database connection settings returned by db_connect_postgis or db_create_postgis.

geom

The feature(s) to intersect. Can also be an Extent object or a 2x2 matrix where the first row is X min,max and the second row is Y min,max.

outpath

A path and filename for the output GeoTIFF file.

with.purpose

Either 'general' (default) to export rasters for general purpose imagery or 'postfire' to export rasters for specially flown, post-fire imagery. May be abbreviated.

time.interval

If provided, only export data for rasters where the scan time (capture_start and capture_end fields) overlap the given interval. Can be provided as either a vector of one or more years as four-digit integers, or a lubridate::interval object.

default.epsg

EPSG code to assume for the query feature(s). Ignored if the features are sf or raster::Extent objects with a coordinate reference system defined.

overlap.action

A character string specifying how to choose between overlapping tiles. Two tiles are considered to be overlapping if the centroid of the first tile lies within the bounds of the second tile. In such cases, only one of the tiles should be exported, otherwise the UNION SUM operation that is applied to merge edge pixels of adjacent rasters will inadvertently sum the values of the overlapping tiles. Options are: 'latest' (default) to choose the most recent tile; 'earliest' to choose the earliest tile; 'year' to apply a preference order of years specified via the overlap.yearorder parameter; 'fail' to abort the export process and issue an error message if overlapping tiles are detected.

overlap.yearorder

A vector of one or more four digit year numbers specifying the preference order to apply when overlapping LAS tiles are detected. Only used if parameter overlap.action is set to 'year', The first element in the vector is the most preferred. Overlapping tiles for years that are not specified in this vector will not be exported.

Value

A list with the following elments:

counts

A RasterStack linked to the GeoTIFF file exported by the function, with layer names corresonding to those defined in the StrataCERMB lookup table from the CERMBlidar package.

dates

A RasterLayer having the same row and column dimensions as the counts raster, where cell values are LiDAR capture dates coded as eight digit integers (yyyymmdd). Cells located within the common edge of adjacent tiles with different capture dates are assigned the date of the earlier tile.


mbedward/CERMBlidarpostgis documentation built on Nov. 14, 2021, 7:15 p.m.