Analysing spatial point patterns in R - CSIRO
Analysing spatial point patterns in R - CSIRO
Analysing spatial point patterns in R - CSIRO
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
63<br />
10 Pixel images <strong>in</strong> spatstat<br />
An object of class "im" represents a pixel image. It specifies a rectangular grid of locations<br />
(“pixels”) <strong>in</strong> two dimensional space, and a numerical value for each pixel. The pixel values<br />
can be real numbers, <strong>in</strong>tegers, complex numbers, s<strong>in</strong>gle characters or str<strong>in</strong>gs, logical values or<br />
categorical values. A pixel’s value can also be NA, mean<strong>in</strong>g that it is not def<strong>in</strong>ed at that location.<br />
A pixel image represents a <strong>spatial</strong> function Z(u) <strong>in</strong> many different contexts. It may conta<strong>in</strong><br />
experimental data (such as a map of terra<strong>in</strong> elevation) or computed values (such as a kernel<br />
estimate of <strong>po<strong>in</strong>t</strong> process <strong>in</strong>tensity) or it may be directly obta<strong>in</strong>ed from a camera (such as a<br />
satellite image).<br />
10.1 Creat<strong>in</strong>g a pixel image<br />
10.1.1 Creat<strong>in</strong>g an image from raw data<br />
To create a pixel image from raw data, use im:<br />
> im(mat, xcol, yrow)<br />
where mat is a matrix conta<strong>in</strong><strong>in</strong>g the pixel values. The pixel values could have been generated<br />
by hand, or read from a file.<br />
The correspondence between matrix <strong>in</strong>dices mat[i,j] and cartesian coord<strong>in</strong>ates is slightly<br />
idiosyncratic: the rows ofmcorrespond to the y coord<strong>in</strong>ate, and the columns to the x coord<strong>in</strong>ate.<br />
The argument xcol is a vector of equally-spaced x coord<strong>in</strong>ate values correspond<strong>in</strong>g to the<br />
columns of mat, and yrow is a vector of equally-spaced y coord<strong>in</strong>ate values correspond<strong>in</strong>g to<br />
the rows of mat. These vectors determ<strong>in</strong>e the <strong>spatial</strong> position of the pixel grid. The length of<br />
xcol is ncol(mat) while the length of yrow is nrow(mat). If mat is not a matrix, it will be<br />
converted <strong>in</strong>to a matrix with nrow(mat) = length(yrow) and ncol(mat) = length(xcol).<br />
> vec mat noisy plot(noisy)<br />
noisy<br />
−5 0 5<br />
Copyright<strong>CSIRO</strong> 2010