Example Resource

Using Point Statistics For Geo Data Analysis

Source Notebook

Using Point Statistics For Geo Data Analysis

 

Examples

Second order point statistics are homogeneity measures of how uniformly the points are distributed within the observation window. They are used to study data locations in relation to other data points.

Location of pharmacies in a part of Madrid city:

In[1]:=
locs = GeoPosition[CompressedData["
1:eJwVknswlFEYxjdMpq0ziUKJMqgkkmltaJey1E5X0qQLItWUa0OhEjVqXULt
MuyQFivkfsndzjFtaciEmRqXwiQlWTMUoWw9+8c33/zmOc/7vO97jrFfiPtF
NQaDsRuf6j9eYZTPZfOcZk+n53MrCbXPrKvNB49tcMpYLSH0X89lzW6w1+bH
fxrKCe1saRImg7+vyE4kxYT6V7jmmu3hOTFFJ5nvSgiVxo8EzkFvvZE7GFdL
6PjS+TNt0DvOxsq3ZBFq/JKtPA89MNmo2aCC0H3WOeZi8IW51F4+zq8NlHEW
wWqsbR1CMaHFGk+dp+HXXTP26AT6MS919LKx4zmp+zK/fkC/H6RnH9ZC73kZ
YuCVR6gzb2j+M/wZzFMcqyZCU+eXHlSDLw+HcgVVhCbqcqNrwB4BWQGy54RG
CsS92WCJRsMZ7UZCE/RMJ3egfs3gt/cm1YQWzcTmiaBP35txiERe2IImo1N1
XqedL0feChsLrhK8LPhi21roGTrR+T1gsbZv2L4cQiOksugS8GHDJyK1Iujs
Rgcm+lWueuFjW0/o7P4qz0pVP9yP9sXPCNUTsAs5yBckDBK9QkIlB0qUEui/
ckzfSGSE1u1KStOF3yvq/vaqVkJt333ZuBfMULC83VAv1JCt7Q5mhd88aNJC
qNYllyQB/O1ShYkH5h06zukPh/57szKI1hEaF9e7zg88p2/Au4r81z5u+nbg
Y2mXBhmY32zatN5Ktd9lr1nh0GPMI6+kgm8Pt2fWY777Gc5COeovbf3kb4r8
muSdRXegt32VB+rWEGqVN6q1CdzlXDYa1Uzo4dIjJzTB/ikFh8rgV678kaMA
vwryeXsul9DbbxcaysEWE0JvCfzXJ4S7g8FGEdviWZjf87m48CjY0fqPbBT7
DP3Spe6H/MRrkz/qMB/Z47Gcj/3tEhhopOC+FYv8pb/QFesLV5Xh/XWns6ZU
9xvT1ddHSgntt7l1VI56Plq5Iy7Yx8AFYzdL6KIp1xhDzDPA/zlVBD9HK8py
Ef27qT8oiMf5qrm79Yl4L/8Bpi50/Q==
"]];

Create SpatialPointData with the observation region inferred from the data points:

In[2]:=
data = SpatialPointData[locs]
Out[2]=

Visualize the data:

In[3]:=
GeoListPlot[data]
Out[3]=

Test if the locations are random:

In[4]:=
SpatialRandomnessTest[data, "TestDataTable"]
Out[4]=
In[5]:=
SpatialRandomnessTest[data, "TestConclusion"]
Out[5]=

So it looks like the locations are random, but are they arbitrarily close to each other? For the answer we compute NearestNeighborG:

In[6]:=
nng = NearestNeighborG[data]
Out[6]=

Compute maximum radius for the point statistics function:

In[7]:=
maxR = nng["MaxRadius"]
Out[7]=

Maximum radius magnitude in meters:

In[8]:=
maxRm = QuantityMagnitude[maxR, "Meters"]
Out[8]=

Visualize:

In[9]:=
DiscretePlot[nng[Quantity[x, "Meters"]], {x, 0, maxRm, maxRm/100}, AxesLabel -> {"m"}]
Out[9]=

So the plot of the NearestNeighborG of the data indicates that pharmacies cannot be arbitrarily close to each other. The limiting distance is called hardcore radius and such data can be modelled by a HardcorePointProcess:

In[10]:=
eproc = EstimatedPointProcess[data, HardcorePointProcess[\[Mu], r, 2]]
Out[10]=

Estimated hardcore radius is:

In[11]:=
r = UnitConvert[eproc[[2]], "Meters"]
Out[11]=

Since the pharmacies cannot be arbitrarily close to each other we can ask what is the expected number of pharmacies within given distance from a given pharmacy - that is how big is the competition within the given radius. This can be answered using another point statistics function - RipleyK:

In[12]:=
funK = RipleyK[data]
Out[12]=

The product of the value of RipleyK at r and the mean point density gives the expected number of points within distance r of a typical point, not counting the point itself:

In[13]:=
DiscretePlot[ funK[Quantity[x, "Meters"]]*MeanPointDensity[data], {x, 0, maxRm, maxRm/100}, AxesLabel -> {"m"}]
Out[13]=

What is the radius within which the expected number of pharmacies is at least 1?

In[14]:=
SelectFirst[ Table[{k, funK[Quantity[k, "Meters"]]*MeanPointDensity[data]}, {k, 100, 200}], (Last[#] >= 1 &)]
Out[14]=

The expected number of pharmacies is at least 1 within the radius of at least 149 meters.

Now let’s compute the probability of encountering a pharmacy within given distance starting from a random location in the observation region which is not a point of the data. The point statistics to do so is EmptySpaceF:

In[15]:=
esF = EmptySpaceF[data]
Out[15]=

Value of EmptySpaceF at r gives exactly the probability of finding a point within distance r of an arbitrary location which is typically not a point of data set:

In[16]:=
DiscretePlot[esF[Quantity[x, "Meters"]], {x, 0, maxRm, maxRm/100}, AxesLabel -> {"m"}]
Out[16]=

The probability of encountering a pharmacy within 100 meters of a random location in the observation region is:

In[17]:=
esF[Quantity[100, "Meters"]]
Out[17]=

Source Metadata

Publisher Information