# NOT RUN {
require(uavRst)
##- Straightforward example to generate a DTM
based on the class 2 minimum returns of a LiDAR file
# get a las file from the Spain authorithy (29.2 MB)
# Source: (https://b5m.gipuzkoa.eus/url5000/es/G_22485/PUBLI&consulta=HAZLIDAR)
utils::download.file(url="https://b5m.gipuzkoa.eus/lidar/MT13_08_au_las.zip",
destfile="MT13_08_au_las.zip", mode = "wb")
unzip("MT13_08_au_las.zip",junkpaths = TRUE,overwrite = TRUE)
##- extract extent for setting up GRASS region
ext<-lastool(lasFile = "MT13_08_au.las")
## according to the meta data
# source: https://b5m.gipuzkoa.eus/web5000/en/csw/MT13_08_au_en
# the projection is EPSG25830. NOTE it is obligate to at the zero transformation params
proj4 = "+proj=utm +zone=30 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"
##- set up GRASS
result<-link2GI::linkGRASS7(spatial_params = c(ext[2],ext[1],ext[4],ext[3],proj4),
resolution = 5.0)
##- use the r.in.lidar tool to generate a pseudo surface model
r_in_lidar(input = "MT13_08_au.las",
output = "dem",
method = "min",
resolution = 5,
class_filter = 2)
##- visualize it
raster::plot(raster::raster(rgrass7::readRAST("dem")))
# }
Run the code above in your browser using DataLab