writeDTM: FUSION R command line interface - Write DTM format files from...

View source: R/UtilityFunctions.R

writeDTMR Documentation

FUSION R command line interface – Write DTM format files from a matrix, RasterLayer, or SpatRaster object

Description

writeDTM writes FUSION's DTM format files from data contained in a matrix, RasterLayer, or SpatRaster object. Any NA values in the data are converted to a value of -1 indicating areas with invalid data. This means that values must all be greater than 0 for use with any of the FUSION tools. While it is possible to store data with negative values, there are much better formats for data than FUSION's DTM format.

Usage

writeDTM(
  x,
  fileName = NULL,
  description = "DTM written by fusionwrapr R package",
  xyunits = NULL,
  zunits = NULL,
  coordsys = NULL,
  zone = NULL,
  horizdatum = NULL,
  vertdatum = NULL,
  originX = NULL,
  originY = NULL,
  columnSpacing = NULL,
  rowSpacing = NULL,
  rotate = TRUE,
  storageFormat = -1
)

Arguments

x

(required): data object containing the values to be written to the DTM file. This can be a simple matrix, a SpatRaster object, or a SpatialLayer object. Values are assumed to be in rows with the first row and column in the upper left corner. Use rotate = FALSE if values are in columns with the first column and row in the lower left corner (same arrangement as FUSION's DTM files).

fileName

character (required): Name for the DTM format file.

description

character: Descriptive name for the DTM. Default is "DTM written by fusionwrapr R package". Length will be truncated to 60 characters.

xyunits

character (required): Units for LIDAR data XY (M for meters, F for feet, O for other or unknown).

zunits

character (required): Units for LIDAR data elevations (M for meters, F for feet, O for other or unknown).

coordsys

numeric (required): Coordinate system for LIDAR data: 0 for unknown 1 for UTM 2 for state plane)

zone

numeric (required): Coordinate system zone for LIDAR data (0 for unknown).

horizdatum

numeric (required): Horizontal datum: 0 for unknown 1 for NAD27 2 for NAD83

vertdatum

numeric (required): Vertical datum: 0 for unknown 1 for NGVD29 2 for NAVD88 3 for GRS80

originX

numeric (required when x is matrix): X value for origin (lower left point in x).

originY

numeric (required when x is matrix): Y value for origin (lower left point in x).

columnSpacing

numeric (required when x is matrix): Spacing between columns.

rowSpacing

numeric (required when x is matrix): Spacing between rows.

rotate

boolean: Flag indicating grid of values needs to be rotated before being written to fileName. See the description of x for details regarding the expected arrangement of values in the grid.

storageFormat

integer: Integer value indicating the numeric type for values stored in the DTM file. The default value (-1) indicates that the actual data type of the data object is used to dictate the appropriate format. Storage options when storageFormat = -1 are 2-byte signed integers for integer values and 4-byte floating point numbers for non-integer values. Possible values are: 0: 2-byte signed integers, 1: 4-byte signed integers, 2: 4-byte floating point numbers, and 3: 8-byte floating point numbers. Storing floating point values as integers will force truncation of the values.

Details

FUSION DTM format files do not carry any projection information that is useful to other tools. FUSION tools use the minimal projection information stored in DTM files to prevent merging of files with different projections or mixing analyses using files with different projections. The enforcement for projection-related information is fairly lax in FUSION's tools and, while I would like to enhance this information, it is not likely to change.

This function is particularly useful for converting surfaces into the DTM format. A simple test using the raster package to read a surface in TIF format and write to the DTM format was over 10 times faster that using gdal_translate to convert the TIF file to ASCII raster and then using FUSION's ASCII2DTM program to convert to DTM format.

Value

Returns an invisible boolean value indicating success (TRUE) or failure (FALSE).

See Also

Other helpers: readDTM(), readLDA()

Examples

## Not run: 
writeDTM(rast, "test.dtm")

## End(Not run)

bmcgaughey1/fusionwrapr documentation built on Dec. 1, 2024, 7:13 a.m.