Anyone have advice for retaining (or appending) attributes from a Spatial Polygons Data Frame after conversion to an owin object for pattern analysis in Spatstat?
Using spatstat to calculate point intensities across a tesselated surface. No issue with this except I lose the polygon labels when I convert the Spatial Polygons Data Frame to an owin object (and subsequently a tess object). See sample code. Thanks!
SF <- readOGR(dsn="D:/",layer="sf")
class(SF) # "SpatialPolygonsDataFrame"
# Convert SpatialPolygonsDataFrame to OWIN object for use in spatstat package
y <- as(SF, "SpatialPolygons")
p <- slot(y, "polygons")
v <- lapply(p, function(z) { SpatialPolygons(list(z)) })
winlist <- lapply(v, as.owin)
# establish window needed for creating tesseslated surface
SF2 <- as(SF, "owin")
# create tesselates surface
e <-tess(tiles = winlist, window = SF2)
## compute counts and density values, across tessellated area, of point data
# B - point pattern object created from *.csv of point locations
QB <- quadratcount(B, tess = e) # tally counts of 'biotic pseudo-variables' by tess tiles
Qi.B <- intensity(QB) # Compute intensity
# Plot results
plot(intensity(QB, image=TRUE), las=1, main=NULL) # plot tess units using intensity for legend
plot(B, pch=20, cex=0.5, col="white", add=TRUE)```