# [R-sig-Geo] Spatial indexing of a point pattern

Rolf Turner r.turner at auckland.ac.nz
Thu Jan 17 00:04:47 CET 2013

```If you are analysing point pattern data,  you should probably be using
"spatstat".

Here is a toy example of how you might determine the index of the quadrat
in which each of the points of your pattern lie:

require(spatstat)

# Simulate a pattern
set.seed(42)
X <- rpoispp(100) # By default the observation window is the unit square.

# Cut X by Q
XQ <- cut(X,z=Q)

# Look at which quadrat the points fall into:
marks(XQ)

# If you want the *number* of each quadrat:
n <- factor(marks(XQ),labels=1:16)

plot(as.owin(X),main="")
text(X\$x,X\$y,labels=n))

# If you want to number along columns rather than along rows:
tQ <- tiles(Q)
tQ2 <- tQ[matrix(1:16,4,4,byrow=TRUE)] # Reordering the quadrats.
Q2   <- tess(tiles=tQ2)
XQ2 <- cut(X,z=Q2)
n2 <- factor(marks(XQ2),labels=1:16)

# Plot the quadrat numbers with the new ordering:
plot(as.owin(X),main="")
text(X\$x,X\$y,labels=n2))

HTH

cheers,

Rolf Turner

On 01/17/2013 02:40 AM, Aurelie C.Godin wrote:
> Hello,
> I have a point pattern and a tessellation (grid). Is there a way to
> spatially index each of my points? In other words, my tessellation grid has
> /n/ quadrats, I would like to know for each of my points which of these
> /(1:n)/ quadrats they are associated with.
> If not, is there another way to do so?
> Many thanks for your suggestions!

```