Tessellation error in spatstat - Error in as.im.default(image) : Can't convert X to a pixel image

129 Views Asked by At

I have been dealing with this for several days and can't find a way out. I'm using spatstat in R for spatial analysis of my cells. I have follow some tutorials, but as always happens, things don't come out as they should. I have some xy coordinates and I am generating a density layer with kde2d. However, when I try to perform the Tessellation (tess function) I get the following error. I have not been able to get around it. I hope you can offer me some help.

Iba1_kde = kde2d(Iba1_Section5$Iba1_Coor_X, Iba1_Section5$Iba1_Coor_Y, n = 200)
contour(Iba1_kde)

Iba1_Raster = raster(Iba1_kde)
Iba1_Frame = as.data.frame(Iba1_Raster , xy = T)

Cell_density <- Iba1_Frame$layer
b <- quantile(Cell_density, probs = (0:5)/5)
Cut <- cut(Cell_density, breaks = b, labels = 1:5)
tess <- tess(image = Cut)

Error in as.im.default(image) : Can't convert X to a pixel image

I appreciate your feedback

0

There are 0 best solutions below