Вы находитесь на странице: 1из 2

TUTORIAL RLIDAR

# Load needed packages


library(raster)
library(rgdal)

# set working directory to data folder


#setwd("pathToDirHere")

# assign raster to object


dsm <- raster("SJER/DigitalSurfaceModel/SJER2013_DSM.tif")

# view info about the raster.


dsm

## class : RasterLayer
## dimensions : 5060, 4299, 21752940 (nrow, ncol, ncell)
## resolution : 1, 1 (x, y)
## extent : 254570, 258869, 4107302, 4112362 (xmin, xmax, ymin, ymax)
## coord. ref. : +proj=utm +zone=11 +datum=WGS84 +units=m +no_defs +ellps=WGS84
+towgs84=0,0,0
## data source : /Users/mjones01/Documents/data/NEON-DS-Field-Site-Spatial-
Data/SJER/DigitalSurfaceModel/SJER2013_DSM.tif
## names : SJER2013_DSM

# plot the DSM


plot(dsm, main="LiDAR Digital Surface Model \n SJER, California")

# import the digital terrain model


dtm <- raster("SJER/DigitalTerrainModel/SJER2013_DTM.tif")

plot(dtm, main="LiDAR Digital Terrain Model \n SJER, California")

# use raster math to create CHM


chm <- dsm - dtm

# view CHM attributes


chm

## class : RasterLayer
## dimensions : 5060, 4299, 21752940 (nrow, ncol, ncell)
## resolution : 1, 1 (x, y)
## extent : 254570, 258869, 4107302, 4112362 (xmin, xmax, ymin, ymax)
## coord. ref. : +proj=utm +zone=11 +datum=WGS84 +units=m +no_defs +ellps=WGS84
+towgs84=0,0,0
## data source : in memory
## names : layer
## values : -1.399994, 40.29001 (min, max)

plot(chm, main="LiDAR Canopy Height Model \n SJER, California")

# Create a function that subtracts one raster from another


#
canopyCalc <- function(DTM, DSM) {
return(DSM -DTM)
}

# use the function to create the final CHM


chm2 <- canopyCalc(dsm,dtm)
chm2

## class : RasterLayer
## dimensions : 5060, 4299, 21752940 (nrow, ncol, ncell)
## resolution : 1, 1 (x, y)
## extent : 254570, 258869, 4107302, 4112362 (xmin, xmax, ymin, ymax)
## coord. ref. : +proj=utm +zone=11 +datum=WGS84 +units=m +no_defs +ellps=WGS84
+towgs84=0,0,0
## data source : in memory
## names : layer
## values : -40.29001, 1.399994 (min, max)

# or use the overlay function


chm3 <- overlay(dsm,dtm,fun = canopyCalc)
chm3

## class : RasterLayer
## dimensions : 5060, 4299, 21752940 (nrow, ncol, ncell)
## resolution : 1, 1 (x, y)
## extent : 254570, 258869, 4107302, 4112362 (xmin, xmax, ymin, ymax)
## coord. ref. : +proj=utm +zone=11 +datum=WGS84 +units=m +no_defs +ellps=WGS84
+towgs84=0,0,0
## data source : in memory
## names : layer
## values : -40.29001, 1.399994 (min, max)

Вам также может понравиться