measure_road: Align and measure a road from lidar data

View source: R/als_road.R

measure_roadR Documentation

Align and measure a road from lidar data

Description

From a reference road (spatial line), extracts the line with a buffer from the point cloud and computes the exact positioning of the road (realignment). Then, using new the accurate shape, computes road metrics including its width, its drivable width, its sinuosity as well as its state in four classes. The function st_snap_lines allows to post-process the output to fix minor inaccuracies and reconnect the roads that may no longer be connected because each road is processed independently.

Usage

measure_road(
  ctg,
  centerline,
  dtm = NULL,
  conductivity = NULL,
  water = NULL,
  param = alsroads_default_parameters,
  ...
)

measure_roads(
  ctg,
  roads,
  dtm,
  conductivity = NULL,
  water = NULL,
  param = alsroads_default_parameters
)

Arguments

ctg

a non-normalized LAScatalog object from lidR package

centerline

a single linestring (sf format) used as reference to search and measure the road.

dtm

RasterLayer storing the DTM with a resolution of at least of 1 m. Can be computed with grid_terrain. It can be missing if a conductivity layer is provided

conductivity

RasterLayer storing the pre-computed conductivity. It can be NULL in this case if will be computed on the fly but the layer can be pre-computed with rasterize_conductivity

water

a set of spatial polygons (sf format) of water bodies. This is used to mask the water bodies so they cannot be mistaken as a drivable surfaces. Not mandatory but can help. It also allows to detect bridges above water.

param

a list of many parameters. See alsroads_default_parameters.

...

unused

roads

multiple lines (sf format) used as reference to search and measure the roads

Value

An sf object similar to the input with additional attributes and an updated geometry. If the class is 3 or 4 the original geometry is preserved to prevent adding more error. The new attributes are ROADWITH, DRIVABLEWIDTH, PERCABOVEROAD (percentage of points between 0.5 and 5 meter above the road) SHOULDERS (average number of shoulders found), SINUOSITY, CONDUCTIVITY (conductivity per linear meters) SCORE (a road state score) and CLASS (4 classes derived from the SCORE). See references

References

Roussel, J.-R., Bourdon, J.-F., Morley, I. D., Coops, N. C., & Achim, A. (2022). Correction , update , and enhancement of vectorial forestry road maps using ALS data a pathfinder and seven metrics. International Journal of Applied Earth Observation and Geoinformation, 114(September), 103020. https://doi.org/10.1016/j.jag.2022.103020

Examples

library(lidR)
library(sf)
library(raster)

dir  <- system.file("extdata", "", package="ALSroads")
road <- system.file("extdata", "j5gr_centerline_971487.gpkg", package="ALSroads")
dtm  <- system.file("extdata", "j5gr_dtm.tif", package="ALSroads")
ctg  <- readLAScatalog(dir)
road <- st_read(road, "original", quiet = TRUE)
dtm  <- raster(dtm)

# Voluntarily add more error to the road
crs <- st_crs(road)
st_geometry(road) <- st_geometry(road) + st_sfc(st_point(c(-8, 0)))
st_crs(road) <- crs

plot(dtm, col = gray(1:50/50))
plot(ctg, add = TRUE)
plot(st_geometry(road), add = TRUE, col = "red")

res <- measure_road(ctg, road, dtm = dtm)
res
poly <- sf::st_buffer(res, res$ROADWIDTH/2)

plot(dtm, col = gray(1:50/50))
plot(st_geometry(road), col = "red", add = TRUE) # Inaccurate road track
plot(st_geometry(res), col = "blue", add = TRUE) # Corrected road track

domain <- "https://servicesmatriciels.mern.gouv.qc.ca:443"
path <- "/erdas-iws/ogc/wmts/Inventaire_Ecoforestier/Inventaire_Ecoforestier/default/"
tiles <- "GoogleMapsCompatibleExt2:epsg:3857/{z}/{y}/{x}.jpg"
url <- paste0(domain, path, tiles)
m = mapview::mapview(list(road, poly),
  layer.name = c("Inaccurate", "Corrected"),
  color = c("red", "blue"), map.type = "Esri.WorldImagery")
leaflet::addTiles(m@map, url)

## Not run: 
conductivity <- system.file("extdata", "j5gr_conductivity.tif", package="ALSroads")
conductivity <- raster(conductivity)
plot(conductivity, col = viridis::viridis(50))

res <- measure_road(ctg, road, conductivity = conductivity)

plot(st_geometry(road), col = "red") # Inaccurate road track
plot(st_geometry(res), col = "blue", add = TRUE) # Corrected road track

## End(Not run)

Jean-Romain/MFFProads documentation built on Nov. 19, 2024, 5:12 p.m.