hull_model | R Documentation |
The hull model predicts that a species is present at sites inside the a hull that contains the training points, and is absent outside that circle.
The hull can be "convex", "circle", or "rectangle"
## S4 method for signature 'SpatVector'
hullModel(p, type="convex", n=1)
## S4 method for signature 'data.frame'
hullModel(p, type="convex", crs="", n=1)
## S4 method for signature 'matrix'
hullModel(p, type="convex", crs="", n=1)
p |
point locations (presence). Two column matrix, data.frame or SpatVector |
type |
character. The type of hull. One of "convex", "circle", or "rectangle" |
crs |
character. The coordinate reference system |
n |
positive integer. The number of hulls to make |
hull_model
r <- rast(system.file("ex/logo.tif", package="terra"))
#presence data
pts <- matrix(c(17, 42, 85, 70, 19, 53, 26, 84, 84, 46, 48, 85, 4,
95, 48, 54, 66, 74, 50, 48, 28, 73, 38, 56, 43, 29, 63, 22, 46, 45,
7, 60, 46, 34, 14, 51, 70, 31, 39, 26), ncol=2)
train <- pts[1:12, ]
test <- pts[13:20, ]
ch <- hullModel(train, crs="+proj=longlat")
predict(ch, test)
plot(r)
plot(ch, border="red", lwd=2, add=TRUE)
points(train, col="red", pch=20, cex=2)
points(test, col="black", pch=20, cex=2)
pr <- predict(ch, r)
plot(pr)
points(test, col="black", pch=20, cex=2)
points(train, col="red", pch=20, cex=2)
# to get the polygons:
p <- geometry(ch)
p
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.