# How to create two Windows in spatstat for the same dataset?

Spatial patterns: I have a dataset of coordinates and marks (diameter) attributed to the points. I am trying to create a window (owin()) for each plot (I have 2 plots), but I don't know how to set the window for both plots:

My window:

``````#data: rea_spd "SpatialPointsDataFrame'
w <- owin(xrange = c(min(rea_spd\$Longitude_), max(rea_spd\$Longitude_)),
yrange=c(min(rea_spd\$Latitude_N), max(rea_spd\$Latitude_N)))
plot(w)
#this produces a window for all the data, but I don't know how to adapt it to have a window for each plot.
#After, I calculated Kcross, which works, but I still need to have two windows, otherwise, I will violate the statistical assumptions:
kmultrea <- envelope(reav, Kcross, nsim=999, i="A", j="S",
global=F, savefuns=TRUE, conf.level= 0.95)
plot(kmultrea,main="Cross-K - Protected area", xlab = "Distance r [m]",
xlim = c(0,30), ylim=c(0, 6000), legend = F)
pk <- LF.gof(kmultrea) #
pk
``````

I tried to follow this example, but I still do not receive the points inside the windows:

``````m = matrix(0,20,20)
m[1+20*cbind(c\$x,c\$y)]=1
plot(pp1)
``````

Determining if trees within forest gaps are clustered using R? I think I have found the solution:

``````#Define ppp and owin window:                                                          poi_rr1 <- as.ppp(poi1)
ww <- as.owin(poly1)
poi_rr1 <- poi_rr1[ww]
marks(poi_rr1) <- factor(poi_rr1\$marks\$TypeD)

# ESTIMATE BANDWIDTH
bw1 <- bw.diggle(poi_rr1, correction="isotropic", hmax=NULL, nr=400)

#Calculate Kcross
kcross1 <- envelope(poi_rr1, Kcross, nsim=99, i="A", j="S", correction = "isotropic", bw = 9.380343, global=F, savefuns=TRUE, conf.level= 0.95)
``````