0

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

  • You are not using data formats from spatstat, so the spatstat function `tess()` doesn't understand your input which is probably a RasterLayer. I'm on my phone so can't give details, but start with converting your x,y data to `ppp` then use `density()` for KDE and then `tess()` should work on the result. – Ege Rubak Apr 24 '22 at 20:30
  • Dear Ege, you gave me the key for solving the issue. I was able to generate the tests object. I appreciate your time and feedback. – Daniel Manrique Apr 25 '22 at 14:55
  • Great that you solved it. You could consider answering your own question so future users can see exactly how you solved the problem. – Ege Rubak Apr 26 '22 at 07:47

0 Answers0