SpatEntropy (version 0.1.0)

areapart: Area partition.

Description

This function partitions the observation area in a number of sub-areas, and assigns the data points/pixels to the areas.

Usage

areapart(win, G, data.coords)

Arguments

win

The observation area, an object of class owin, see package spatstat.

G

An integer if sub-areas are randomly generated, determining the number \(G\) of sub-areas. Alternatively, a \(G\)x\(2\) matrix with the sub-areas centroids' coordinates.

data.coords

A two column matrix. If the dataset is a point pattern, the point coordinates. If the dataset is a raster/pixel matrix, the centroids' coordinates, provided by user or returned by coords_pix().

Value

A list with elements:

  • G.coords a point pattern containing the \(G\) areas' centroids

  • data.assign a three column matrix, where each pair of data coordinates is matched to one of the \(G\) areas (numbered 1 to \(G\)).

Details

An event of interest (in the form of a point or binary areal dataset) occurs over an observation area divided into sub-areas. If the partition is random, this function generates the sub-areas by randomly drawing the areas' centroids over the observation window. Then, data points/pixels are assigned to the area with the closest centroid.

Examples

Run this code
# NOT RUN {
#LATTICE DATA
#random generation of areas
ccc=coords_pix(area=square(10), nrow=10, ncol=10)
partition=areapart(square(10), G=5, data.coords=ccc)

#providing a pre-fixed area partition
win=square(10)
G=5
GG=cbind(runif(G, win$xrange[1], win$xrange[2]),
         runif(G, win$yrange[1], win$yrange[2]))
ccc=coords_pix(area=win, pixel.xsize = 2, pixel.ysize = 2)
partition=areapart(win, G=GG, data.coords=ccc)

#POINT DATA
#random generation of areas
data.pp=runifpoint(100, win=square(10))
marks(data.pp)=sample(c("a","b","c"), 100, replace=TRUE)
ccc=coords(data.pp)
partition=areapart(square(10), G=4, data.coords=ccc)

#providing a pre-fixed area partition
win=square(10)
G=4
GG=cbind(runif(G, win$xrange[1], win$xrange[2]),
         runif(G, win$yrange[1], win$yrange[2]))
data.pp=runifpoint(100, win=win)
marks(data.pp)=sample(c("a","b","c"), 100, replace=TRUE)
ccc=coords(data.pp)
partition=areapart(win, G=GG, data.coords=ccc)

#for plotting the area partiton
?plot_areapart

# }

Run the code above in your browser using DataLab