Learn R Programming

habtools (version 1.1.1)

mesh_to_dem: Transform 3D mesh to DEM

Description

Turns a 3D mesh file into a Digital Elevation Model (DEM) of class RasterLayer format.

Usage

mesh_to_dem(mesh, res, fill = TRUE)

Value

A dem of class RasterLayer.

Arguments

mesh

A mesh3d object.

res

(Optional) The desired DEM resolution in same units at the 3D mesh.

fill

Logical. Fill NA values in raster with minimum value?

Details

The function rasterizes uses the vertices of the mesh file. If resolution is not given, it is calculated by finding the maximum nearest neighbor of vertices projected on the xy plane. fill is used when irregular 3D meshes result in NA values in raster cells. The default is to fill these cells with the minimum, non-NA raster value.

Examples

Run this code
dem <- mesh_to_dem(mcap)
raster::plot(dem)

dem <- mesh_to_dem(mcap, res = 0.05)
raster::plot(dem)

# Don't fill empty raster cells
dem <- mesh_to_dem(mcap, res = 0.02, fill = FALSE)
raster::plot(dem)

Run the code above in your browser using DataLab