[R-sig-Geo] Is it possible to calculate the semivariances of a variogram between one specific point and all other points in space?

Edzer Pebesma edzer.pebesma at uni-muenster.de
Wed Sep 12 11:01:09 CEST 2012



On 09/12/2012 10:29 AM, Laura Wette wrote:
> Hello Edzer,
> 
> I have one last question (at least I hope so) regarding the variogram
> cloud. So now I've got only those rows of the variogram, where I find the
> specific point I want to have by converting into a data frame and then
> extracting the appropriated rows. But I would like to plot the variogram,
> so my question is: Is there any posibility to convert this new data frame
> back into class "variogramCloud"?
> 
> Thank you very much in advance for your answer!
> Regards
> Laura

Yes, but the code looks a bit more ugly without the coercion to data.frame:

> v[((v$np %/% attr(v, ".BigInt"))+1)==1,][1:10,]
        dist       gamma dir.hor dir.ver   id left right
1   70.83784 0.006065804       0       0 var1    2     1
2  118.84864 0.109534743       0       0 var1    3     1
4  259.23927 0.952808244       0       0 var1    4     1
7  366.31407 0.890852716       0       0 var1    5     1
11 473.62960 0.833549786       0       0 var1    6     1
16 258.32151 0.586528972       0       0 var1    7     1
22 252.04960 0.426115526       0       0 var1    8     1
29 380.18943 0.583407369       0       0 var1    9     1
37 471.00849 1.479252663       0       0 var1   10     1
46 510.07548 1.424283374       0       0 var1   11     1
> class(v[((v$np %/% attr(v, ".BigInt"))+1)==1,][1:10,])
[1] "variogramCloud" "data.frame"
> plot(v[((v$np %/% attr(v, ".BigInt"))+1)==1,])

plots the variogram cloud for all point pairs (up to the default
distance) that include point 1. Replacing %/% with %% will get you
selection on the "left" of the point pair:

> gstat:::as.data.frame.variogramCloud
function (x, row.names, optional, ...)
{
    .BigInt = attr(x, ".BigInt")
    x$left = x$np%%.BigInt + 1
    x$right = x$np%/%.BigInt + 1
    x$np = NULL
    class(x) = "data.frame"
    x
}
<environment: namespace:gstat>


> 
> 2012/9/7 Edzer Pebesma <edzer.pebesma at uni-muenster.de>
> 
>> The variogram cloud might be what you're looking for. In the output
>> table, all individual point pairs (up to some spatial separation
>> distance) are reported, and identified by columns "left" and "right".
>> Selecting a point (last example) needs coercion to data.frame first.
>>
>>
>>> library(gstat)
>> Loading required package: sp
>> Loading required package: spacetime
>> Loading required package: zoo
>>
>> Attaching package: ‘zoo’
>>
>> The following object(s) are masked from ‘package:base’:
>>
>>     as.Date, as.Date.numeric
>>
>> Loading required package: xts
>>> loadMeuse()
>>> v = variogram(log(zinc)~1, meuse, cloud=TRUE)
>>> v[1:10,]
>>         dist       gamma dir.hor dir.ver   id left right
>> 1   70.83784 0.006065804       0       0 var1    2     1
>> 2  118.84864 0.109534743       0       0 var1    3     1
>> 3  141.56624 0.167153095       0       0 var1    3     2
>> 4  259.23927 0.952808244       0       0 var1    4     1
>> 5  282.85155 1.110920725       0       0 var1    4     2
>> 6  143.17123 0.416229664       0       0 var1    4     3
>> 7  366.31407 0.890852716       0       0 var1    5     1
>> 8  362.64032 1.043938763       0       0 var1    5     2
>> 9  251.02390 0.375633672       0       0 var1    5     3
>> 10 154.26276 0.001041290       0       0 var1    5     4
>>> plot(v)
>>> vdf = as.data.frame(v)
>>> vdf[vdf$right == 1,][1:10,]
>>         dist       gamma dir.hor dir.ver   id left right
>> 1   70.83784 0.006065804       0       0 var1    2     1
>> 2  118.84864 0.109534743       0       0 var1    3     1
>> 4  259.23927 0.952808244       0       0 var1    4     1
>> 7  366.31407 0.890852716       0       0 var1    5     1
>> 11 473.62960 0.833549786       0       0 var1    6     1
>> 16 258.32151 0.586528972       0       0 var1    7     1
>> 22 252.04960 0.426115526       0       0 var1    8     1
>> 29 380.18943 0.583407369       0       0 var1    9     1
>> 37 471.00849 1.479252663       0       0 var1   10     1
>> 46 510.07548 1.424283374       0       0 var1   11     1
>>
>>
>> On 09/07/2012 11:52 AM, Laura Wette wrote:
>>> Hello all,
>>>
>>> I searched the internet very long for an answer, but didn't find one, so
>> I
>>> hope you can help me.
>>>
>>> I have to test several study sites for representativeness for the
>>> environment and therefore I have remotely sensed raster data, which
>>> reproduce the NDVI (Normalized Differenced Vegetation Index). The pixel
>>> values vary between -1 and 1. I've also got the coordinates of the study
>>> sites' centers and all the coordinates for all pixels and their values.
>>>
>>> For this purpose I decided to calculate variograms for the study sites
>> and
>>> their environment with the variog()-function of the geoR-Package.
>>> Unfortunately, with this function it is only possible to calculate the
>>> semi-variances for each pair of points in the investigated area and not
>> for
>>> pairs of one specific point and any other point (if I understood the R
>>> Documentation correctly). So the calculated semi-variances have nothing
>> to
>>> do with study sites, as they have no spatial connection. Could you please
>>> tell me, if it is possible to calculate these variograms with a given
>>> starting point? I.e. is it possible to calculate the semivariances
>> between
>>> one specific point( the "starting point", which is one study site) and
>> all
>>> other points (the environment of the study sites), which are located in
>>> different distances? Is it possible to do so with variog() or do have to
>>> calculate with other packages like gstat, spatial or nlme?
>>>
>>> In the gstat-manual (www.gstat.org/gstat.pdf) I found a so-called local
>>> neighbourhood selection. Is there anything similar available for the geoR
>>> package? If not, how can I implement the commands in the
>>> variogram()-function of the gstat-package? Can I use this local
>>> neighbourhood selection at all or is it a wrong aprroach?
>>>
>>> Thank you very much for any answer!
>>> Laura
>>>
>>>       [[alternative HTML version deleted]]
>>>
>>> _______________________________________________
>>> R-sig-Geo mailing list
>>> R-sig-Geo at r-project.org
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>
>>
>> --
>> Edzer Pebesma
>> Institute for Geoinformatics (ifgi), University of Münster
>> Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
>> 8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
>> http://www.52north.org/geostatistics      e.pebesma at wwu.de
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
> 

-- 
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics      e.pebesma at wwu.de



More information about the R-sig-Geo mailing list