prepare_tile: Import and prepare a LAS tile for further processing

View source: R/tile_functions.R

prepare_tileR Documentation

Import and prepare a LAS tile for further processing

Description

This function imports data from a LAS file and prepares it for further processing. Point heights are normalized to relative height above ground, either by fitting a surface model to ground points (plus water points by default) or by taking ground elevations from a provided raster DEM. Height normalization can be disabled if desired. Flight lines are identified based on GPS times for points and, optionally, any flight lines with less than a threshold number of points are discarded. The flightlineID column is added to the LAS header so that it will persist if the object is written to file.

Usage

prepare_tile(
  path,
  normalize.heights = FALSE,
  treat.as.ground = c(2, 9),
  drop.negative = TRUE,
  drop.negative.threshold = 0,
  drop.missing.coords = TRUE,
  fields = NULL,
  classes = NULL,
  min.points = 1000,
  flight.gap = 60,
  unzip.dir = NULL
)

Arguments

path

Path to the LAS or LAZ format file to process. If the file extension is '.zip' it is assumed to be a compressed LAS file that will be unzipped before processing (see the unzip.dir parameter below). A compressed file should contain only one LAS file (identified by having a 'las' or 'LAS' file extension) although it can also contain other files (e.g. HTML or XML documents).

normalize.heights

Whether, and how, to normalize point heights to ground level. Can be one of the following:

A logical value

If TRUE, relative ground level is estimated from an elevation surface fitted by triangulation to ground points in the LAS file. This is equivalent to calling the normalize function directly with the argument algorithm = tin(). If FALSE, point heights will not be normalized.

An algorithm name as a character string

Point heights will be normalized using the specified algorithm. Must be one of: 'tin', 'knnidw', 'kriging' which correspond to the algorithm functions provided by the lidR package.

A raster layer

If a raster layer (a terra package SpatRast object or a raster package RasterLayer object) is provided, the cell values will be used as ground elevation to normalize point heights. The layer should have the same or greater extent as the LAS file.

A raster filename

Any character string that does not match one of the supported algorithm names will be treated as the path to a raster file. Supported formats are GeoTIFF ('.tif') and ESRI ASCII ('.asc'). If the file extension is '.zip' it is assumed to be a compressed file that will be unzipped before processing (see the unzip.dir parameter below). A compressed file should contain only one raster file (identified by having a '.tif' or '.asc' file extension) although it can also contain other files (e.g. HTML or XML documents).

NULL

Same as FALSE, ie. point heights will not be normalized.

The default value is FALSE to leave point heights unchanged. If point heights are normalized, the original values are copied to a new data table column 'Zref', but this is not added to the LAS header by default so if the object is written to file the original heights will be lost.

treat.as.ground

Point classes to treat as ground points when normalizing point heights by interpolation using one of the lidR package algorithms ('tin', 'knnidw', 'kriging'). If point heights are being normalized from a raster DEM, any classes specified by this argument will have their normalized heights set to zero. The default value c(2,9) specifies ground and water classes.

drop.negative

If TRUE AND point heights are being normalized, any points whose heights are more than drop.negative.threshold below ground level will be discarded.

drop.negative.threshold

If drop.negative is TRUE AND point heights are being normalized, any heights more than this threshold value below ground level will be discarded. Default value is zero.

drop.missing.coords

If TRUE (default), discard any points that have missing values for the X, Y or Z coordinates. If FALSE, retain the point but issue a warning message.

fields

Either NULL (default) to include all data fields, or a character string containing single-letter abbreviations for selected fields. See readLAS for details of the available, single-letter field abbreviations.

classes

Point classes to include or exclude. The default (NULL) is to include classes 2 (ground), 3-5 (vegetation), 6 (buildings) and 9 (water). Specify a subset of classes as a vector of integers, e.g. classes = 2:6 would include ground (2), vegetation (3, 4, 5) and building (6) points. Negative values can be used to exclude selected classes, e.g. classes = -6 would include all classes except those classified as building points. Note that overlap points (class 12) are always excluded unless an explicit integer classes vector is provided that includes the value 12.

min.points

The minimum number of points in a flight line for it to be retained in the imported tile. The default value (1000) is intended to exclude flight lines that only appear at the margins of the tile.

flight.gap

The minimum time gap (seconds) to use when assigning points to flight lines.

unzip.dir

The directory in which to uncompress a compressed LAS file (identified by a '.zip' extension). If NULL (default) a temporary directory will be used. After processing, the uncompressed file will be deleted.

Value

A LAS object.


mbedward/CERMBlidar documentation built on April 10, 2024, 2:05 p.m.