Skip to content

how do we sample in spatial statistics?

1 message · Adrian Baddeley

#
Zhijie Zhang writes:
It depends on what kind of data or population you are sampling.

  (a) If your data or population are stored in a vector, a list or a data frame,
  then you can sample some of the items in the list, simply by using
  the R function sample() to select values of the list index.
  For example 
	mydata <- list(.............)
	index <- sample(seq(mydata), 3, replace=FALSE) 
	sam <- mydata[index]
  will select three items at random from the list.

  In package 'spatstat', a pattern of points or a pattern of line segments
  can also be indexed by numerical values. For example
	data(cells)
	index <- sample(cells$n, 3, replace=TRUE)
	sam <- cells[index]
  takes the `cells' dataset, a spatial point pattern, 
  and selects three of the points at random.
	
  (b) If your data are spatially referenced (for example a map of
  temperatures across the ocean), you may want to sample these data
  at `spatially random' locations. In principle you can use any
  random pattern of points to do this. 

  Package 'spatstat' contains a large number of functions for generating
  random patterns of points. Type help(spatstat) for a list of them.
  These functions can be used to sample spatially-referenced data in any package. 

  In spatstat, for example, if ocean temperatures are stored as a pixel image, you can 
  sample them using a point pattern:
	temperature <- im(........)
	samplepoints <- rstrat(temperature$window, 10, 10, 3)
	sam <- temperature[samplepoints]
   creates an image called 'temperature', then generates a stratified random pattern
   of points, and extracts the ocean temperatures at these points.

Adrian Baddeley