# NOT RUN {
# uses the idealised landscapes in 'segdata'
data(segdata)
grd <- GridTopology(cellcentre.offset=c(0.5,0.5),
cellsize=c(1,1), cells.dim=c(10,10))
grd.sp <- as.SpatialPolygons.GridTopology(grd)
test.df <- segdata[,1:2]
# no spatial smoothing
xx1 <- spseg(grd.sp, data = test.df)
print(xx1, digits = 3)
# plots the values in the slot 'data'
spplot(xx1, main = "No spatial smoothing")
# smoothes the data points
xx2 <- spseg(grd.sp, data = test.df, smoothing = "equal")
print(xx2, digits = 3)
spplot(xx2, main = "Equal")
# uses the kernel smoothing of the data points
xx3 <- spseg(grd.sp, data = test.df, smoothing = "kernel",
nrow = 20, ncol = 20)
print(xx3, digits = 3)
spplot(xx3, main = "Kernel")
# }
# NOT RUN {
# same as the above but with a boundary polygon
w <- matrix(c(1.5, 1.5,
1.5, 8.5,
8.5, 8.5,
8.5, 4.5,
5.5, 4.5,
5.5, 1.5), ncol = 2, byrow = TRUE)
xx4 <- spseg(grd.sp, data = segdata[,1:2], smoothing = "kernel",
window = w, nrow = 20, ncol = 20)
print(xx4, digits = 3)
spplot(xx4, main = "Kernel with a boundary polygon")
# retrieves the index values
as.list(xx4)
# shows the values in the slot 'env'
spplot(as(xx4, "SegLocal"), main = "Local population composition")
# }
Run the code above in your browser using DataLab