29.01.2015 Views

Analysing spatial point patterns in R - CSIRO

Analysing spatial point patterns in R - CSIRO

Analysing spatial point patterns in R - CSIRO

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

53<br />

9 Manipulat<strong>in</strong>g <strong>po<strong>in</strong>t</strong> <strong>patterns</strong><br />

Before proceed<strong>in</strong>g, we need to know more about how to manipulate and <strong>in</strong>terrogate <strong>po<strong>in</strong>t</strong> pattern<br />

data.<br />

9.1 Po<strong>in</strong>t pattern objects<br />

A <strong>po<strong>in</strong>t</strong> pattern is represented <strong>in</strong> spatstat by an object of the class "ppp". This conta<strong>in</strong>s the<br />

coord<strong>in</strong>ates of the <strong>po<strong>in</strong>t</strong>s, optional ‘mark’ values attached to the <strong>po<strong>in</strong>t</strong>s, and a description of the<br />

study region or <strong>spatial</strong> ‘w<strong>in</strong>dow’.<br />

9.1.1 Internal Format<br />

WARNING: It is strongly advisable NOT to directly access or modify<br />

the <strong>in</strong>ternal components of an object.<br />

It is a “beg<strong>in</strong>ner’s mistake” to modify the <strong>in</strong>ternal components of a structured object such<br />

as a <strong>po<strong>in</strong>t</strong> pattern (object of class "ppp"). The <strong>in</strong>ternal structure of objects <strong>in</strong> a package can<br />

change from one version of the package to another. It is much safer to use operators def<strong>in</strong>ed <strong>in</strong><br />

the package to extract and modify <strong>in</strong>formation.<br />

However, <strong>in</strong> the spirit of “open source”, here is a description of the <strong>in</strong>ternal format.<br />

A <strong>po<strong>in</strong>t</strong> pattern object P has the follow<strong>in</strong>g components:<br />

P$n is the number of <strong>po<strong>in</strong>t</strong>s (which may be zero).<br />

P$x is a numeric vector conta<strong>in</strong><strong>in</strong>g the x coord<strong>in</strong>ates of the <strong>po<strong>in</strong>t</strong>s. Its length equals P$n<br />

(and may be zero).<br />

P$y is a numeric vector conta<strong>in</strong><strong>in</strong>g the y coord<strong>in</strong>ates of the <strong>po<strong>in</strong>t</strong>s. Its length also equals<br />

P$n.<br />

P$marks conta<strong>in</strong>s the marks. It is either NULL, or a vector of length P$n conta<strong>in</strong><strong>in</strong>g the<br />

mark values, or a data frame with P$n rows conta<strong>in</strong><strong>in</strong>g the mark values. The entries of<br />

P$marks may be of any atomic type (character, numeric, <strong>in</strong>teger, logical, complex) or<br />

factor.<br />

P$w<strong>in</strong>dow is an object of class "ow<strong>in</strong>" (“observation w<strong>in</strong>dow”) determ<strong>in</strong><strong>in</strong>g the study<br />

region or <strong>spatial</strong> ‘w<strong>in</strong>dow’.<br />

It is possible to extract these components <strong>in</strong>dividually; for example, to make a histogram of<br />

the x coord<strong>in</strong>ates you could just type hist(P$x). However, do not assign values to these<br />

components directly, or you may create <strong>in</strong>consistencies <strong>in</strong> the data which cause spatstat to<br />

crash.<br />

To extract or manipulate the data <strong>in</strong> a <strong>po<strong>in</strong>t</strong> pattern object, use the functions provided <strong>in</strong><br />

the package. Important ones are:<br />

n<strong>po<strong>in</strong>t</strong>s(X) number of <strong>po<strong>in</strong>t</strong>s <strong>in</strong> X<br />

marks(X) marks of X<br />

coords(X) coord<strong>in</strong>ates of <strong>po<strong>in</strong>t</strong>s <strong>in</strong> X<br />

as.ow<strong>in</strong>(X) w<strong>in</strong>dow of X<br />

as.data.frame(X) coord<strong>in</strong>ates and marks of X<br />

marks(X)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!