# Longleaf pines data
lon <- longleaf
if(human <- interactive()) {
plot(lon)
}
lon <- lon[seq(1,npoints(lon),by=10)]
# adult trees defined to have diameter at least 30 cm
longadult <- subset(lon, marks >= 30)
if(human){
plot(longadult)
}
# note that the marks are still retained.
# Use unmark(longadult) to remove the marks
# New Zealand trees data
if(human){
plot(nztrees) # plot shows a line of trees at the far right
abline(v=148, lty=2) # cut along this line
}
nzw <- owin(c(0,148),c(0,95)) # the subwindow
# trim dataset to this subwindow
nzsub <- nztrees[nzw]
if(human){
plot(nzsub)
}
# Redwood data
if(human){
plot(redwood)
}
# Random thinning: delete 60% of data
retain <- (runif(npoints(redwood)) < 0.4)
thinred <- redwood[retain]
if(human){
plot(thinred)
}
# Scramble 60% of data
if(require(spatstat.random)) {
X <- redwood
modif <- (runif(npoints(X)) < 0.6)
X[modif] <- runifpoint(ex=X[modif])
}
# Lansing woods data - multitype points
lan <- lansing
# \testonly{
lan <- lan[seq(1, npoints(lan), length=100)]
# }
# Hickory trees
hicks <- split(lansing)$hickory
# Trees in subwindow
win <- owin(c(0.3, 0.6),c(0.2, 0.5))
lsub <- lan[win]
if(require(spatstat.random)) {
# Scramble the locations of trees in subwindow, retaining their marks
lan[win] <- runifpoint(ex=lsub) %mark% marks(lsub)
}
# Extract oaks only
oaknames <- c("redoak", "whiteoak", "blackoak")
oak <- lan[marks(lan) %in% oaknames, drop=TRUE]
oak <- subset(lan, marks %in% oaknames, drop=TRUE)
# To clip or not to clip
X <- unmark(demopat)
B <- owin(c(5500, 9000), c(2500, 7400))
opa <- par(mfrow=c(1,2))
plot(X, main="X[B]")
plot(X[B], add=TRUE,
cols="blue", col="pink", border="blue",
show.all=TRUE, main="")
plot(Window(X), add=TRUE)
plot(X, main="X[B, clip=TRUE]")
plot(B, add=TRUE, lty=2)
plot(X[B, clip=TRUE], add=TRUE,
cols="blue", col="pink", border="blue",
show.all=TRUE, main="")
par(opa)
Run the code above in your browser using DataLab