This session is about reading in, displaying and summarising point patterns. The lecturer’s R script is available here (right click and save).
If you have not already done so, you’ll need to start R and load the spatstat
package by typing
library(spatstat)
We will study a dataset that records the locations of Ponderosa Pine trees (Pinus ponderosa) in a study region in the Klamath National Forest in northern California. The data are included with spatstat
as the dataset ponderosa
.
assign the data to a shorter name, like X
or P
;
plot the data;
find out how many trees are recorded;
find the dimensions of the study region;
obtain an estimate of the average intensity of trees (number of trees per unit area).
The Ponderosa data, continued:
When you type plot(ponderosa)
, the command that is actually executed is plot.ppp
, the plot method for point patterns. Read the help file for the function plot.ppp
, and find out which argument to the function can be used to control the main title for the plot;
plot the Ponderosa data with the title Ponderosa Pine Trees above it;
from your reading of the help file, predict what will happen if we type
plot(ponderosa, chars="X", cols="green")
then check that your guess was correct;
try different values of the argument chars
, for example, one of the integers 0 to 25, or a letter of the alphabet. (Note the difference between chars=3
and chars="+"
, and the difference between chars=4
and chars="X"
).
The following vectors record the locations of 10 scintillation events observed under a microscope. Coordinates are given in microns, and the study region was 30 × 30 microns, with the origin at the bottom left corner.
x <- c(13, 15, 27, 17, 8, 8, 1, 14, 19, 23)
y <- c(3, 15, 7, 11, 10, 17, 29, 22, 19, 29)
Create a point pattern X
from the data, and plot the point pattern (use owin
or square
to define the study region).
The file anthills.txt
is available in the Data directory on GitHub and downloadable by this direct link (right click and save).
It records the locations of anthills recorded in a 1200x1500 metre study region in northern Australia. Coordinates are given in metres, along with a letter code recording the ecological ‘status’ of each anthill (in this exercise we will ignore this letter code).
read the data into R
as a data frame, using the R
function read.table
. (Since the input file has a header line, you will need to use the argument header=TRUE
when you call read.table
.)
check the data for any peculiarities.
create a point pattern hills
containing these data. Ensure that the unit of length is given its correct name.
plot the data.