[R-sig-Geo] MEM : Spatial structures detection issues

Roger Bivand Roger.Bivand at nhh.no
Sun Dec 1 20:53:58 CET 2013


On Sun, 1 Dec 2013, David Bauman wrote:

> My sampled plots are represented by x-y coordinates corresponding to the
> central point of the plots. The euclidean distance matrix is computed from
> this dataframe.
>
> Plot    x    y
> 01a    112.5    12.5
> 02a    112.5    62.5
> 03c    187.5    12.5
> ...
>
> The permanent forest plot is a rectangular area of 200 x 500 m. All this
> area has been divided in 25x25 m plots, from which I sampled 24 more or
> less regularly dispersed over the forest.
>
> What I would like to know is how can I give to R the necessary information
> so that those plots are considered as squared areas of 25x25 m, and not as
> simple points. And when this is done, how do I compute an euclidean
> distance matrix between my 24 plots ?
>
> Which packages/functions allow to do this ?

library(sp)
GT <- GridTopology(c(12.5, 12.5), c(25, 25), c(8, 20))
SG <- SpatialGrid(GT)
bbox(SG) # if the orientation is rotated, reverse the third
# argument to GridTopology()
SPix <- as(SG, "SpatialPixels")
SPol <- as(SPix, "SpatialPolygons")
plot(SPol)
set.seed(1) # emulating your sample
ids <- sample.int(length(SPol), 24)
C_ids <- coordinates(SPol)[ids,] # C_ids are your sample centre points
o <- over(SpatialPoints(C_ids), SPol)
SSPol <- SPol[o]
plot(SSPol, col="yellow", add=TRUE)
text(coordinates(SSPol), label=row.names(SSPol), cex=0.6)
library(rgeos)
GD <- gDistance(SSPol, byid=TRUE) # matrix of distances

gives a matrix of distances between plots.

sp gets most of the way there, finishing with rgeos for distances between 
geometries.

Roger

>
> Thank you
>
>
> 2013/11/30 Roger Bivand <Roger.Bivand at nhh.no>
>
>> On Sat, 30 Nov 2013, David Bauman wrote:
>>
>>  Hi everyone,
>>>
>>> I am facing a problem I really do not know how to resolve about
>>> detecting significant spatial structures in a region I am studying.
>>>
>>> The study is about the Miombo forest (wooded savanna). I am working in
>>> a 10 ha permanent forest plot, where all trees are mapped and
>>> identified. I sampled 24 more or less regulately scattered plots of 25
>>> x 25 m over the 10 ha. In each plot of 25 x 25 m I got 5 soil samples
>>> on which I will measure a battery of variables (the explanatory
>>> variables).
>>> What I want to study is the bêta-diversity of the ectomycorrhizal
>>> community, so that in each plot I got about 15 pieces of root
>>> containing some ectomycorrhizal fungus on it (response variables).
>>>
>>> My purpose is to explain the spatial variation of the ectomycorrhizal
>>> diversity thanks to the soil variables I will have measured.
>>>
>>> To do so, I want to use a PCNM (or MEM).
>>>
>>> My problem is that :
>>>
>>> All the 24 plots are considered as points, so that the euclidean
>>> distance between them is overestimated. Two adjacent, contiguous,
>>> plots are considered to be 25 m far from each other, while the
>>> distance should be 0, since they "touch" each other.
>>>
>>
>> Well, how are you representing the support of the plots? If you are only
>> providing a central point rather than a polygon, you are getting what you
>> asked for. If you are providing polygon boundaries, but using the
>> coordinates() method to return the central points, the same follows. If tou
>> need distances between polygon objects, use gDistance() in rgeos (if your
>> positional data are projected).
>>
>> It always helps if questioners show their reasoning by including a small
>> example with code, as the problem may result from an unfortunate choice of
>> functions in the workflow. Also always include the output of sessionInfo()
>> as functions may behave differently in different versions of R and packages.
>>
>> Hope this clarifies,
>>
>> Roger
>>
>>  This leads me to the problem that the truncation threshold distance is
>>> to high to allow the RDA of the response dataframe on the spatial PCNM
>>> variables to detect a significant linear link between both matrices
>>> (function anova.cca()).
>>>
>>> So the question is : How can I do so that the area of my plots are
>>> taken into account, and they are not considered as points anymore ?
>>> This would lower the truncation distance and probably allow me to
>>> detect spatial structures that, I really think, do exist.
>>>
>>> I hope someone with some experience and good ideas will be able to help.
>>>
>>> If you want some more concrete information about the study, do not
>>> hesitate to ask it to me.
>>>
>>> Thanks a lot,
>>>
>>> David Bauman
>>>
>>> _______________________________________________
>>> R-sig-Geo mailing list
>>> R-sig-Geo at r-project.org
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>
>>>
>> --
>> Roger Bivand
>> Department of Economics, Norwegian School of Economics,
>> Helleveien 30, N-5045 Bergen, Norway.
>> voice: +47 55 95 93 55; fax +47 55 95 95 43
>> e-mail: Roger.Bivand at nhh.no
>>
>

-- 
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no


More information about the R-sig-Geo mailing list