MEG-DM-L12

library(sp)
library(raster)
library(RColorBrewer)
library(latticeExtra)
library(grid)
library(rgdal)

setwd(“C:/Users/hexun/Desktop/DM/W12/L12″)

lidar <- read.table("lidar_example.txt", header = TRUE, sep = ",")
str(lidar)
coordinates(lidar) <- ~X + Y
projection(lidar) <- "+proj=utm +zone=32 +ellps=GRS80 +units=m +north"

unique(lidar$Classification)

trees <- readOGR("trees.shp", layer = "trees")

subset(lidar,lidar$Classification =="13")
clrs <- colorRampPalette(c(rev(brewer.pal(11, "Spectral")), "black"))

yat = seq(5645000, 5647000, 500)
ylabs = paste(yat, "N", sep = "")
xat = seq(472000, 484000, 500)
xlabs = ifelse(xat 0, paste(xat, “E”, sep = “”),
paste(xat, “”, sep = “”)))
raster <- spplot(lidar, zcol = "Z", col.regions = clrs(1000),
scales = list(x = list(at = xat, labels = xlabs),
y = list(at = yat, labels = ylabs)),
colorkey = TRUE, key.space = list(x = 0.1, y = 0.1, corner = c(0, 0)),
main = "LiDAR dataset, ground returns")
treesplot <- spplot(trees[, 1], col.regions = FALSE, col = "green")
print(raster + as.layer(treesplot))

treesplot

Leave a Reply