I have a data frame of a mapped forest plot, where all tree stems have X, Y coordinates, diameter at breast height (in cm), and survival (0,1) (found here, named "MFP14_surv_forSO.csv": https://www.dropbox.com/sh/t10b53qcobvxlzg/AACZyASgudtFLiZ79QRIjHH_a?dl=0).
I created a spatial point pattern and then a smoothed kernel (im object) of large stem death as a proxy for canopy "gappiness" (or amount of light penetration). I consider large stems as those with a diameter >9cm, and a '0' survival indicates the stem died.
I'd like to interpolate this measure of "gappiness" onto all tree stems. I already know that there are several points in the pattern that lie outside the window, so I exclude those from the analysis using inside.owin() to subset the data frame.
surv14 <- read.csv("MFP14_surv_forSO.csv")
win14 <- owin(poly=list(x=c(0,250,250,225,225,0),y=c(0,0,50,50,100,100))) #specifying window extent
surv14 <- surv14[inside.owin(surv14[,1],surv14[,2], win14)==TRUE,] #removing points outside of window
death <- surv14[!is.na(surv14$diam90) & surv14$diam90>9,] #subsetting only large stems
death <- death[death$surv==0,] #subsetting only the large stems that died
death.pp <- as.ppp(death,win14) #creating point pattern from large stem death
death.fun <- Smoothfun(death.pp,sigma=10,edge=TRUE) #smoothed kernel of large stem death
im <- as.im(death.fun) #converting smoothed kernel into im object
ext <- im[surv14[,1:2]] #yields pixel values of gappiness for each stem
surv14 <- cbind(surv14,ext) #adding gappiness measure to data frame
But when I interpolate, it is leaving out one of the points - there are 4873 observations in surv14 and only 4872 in the interpolation, ext. So when I try to bind the measure of gappiness to my data frame using cbind I get the following error message:
Error in data.frame(..., check.names = FALSE) :
arguments imply differing number of rows: 4873, 4872
I don't know how to figure out which point it's leaving out, and why. Any guidance would be greatly appreciated!
