Skip to content
Prev 3514 / 29559 Next

gstat variogram & great circle distance

Hi Edzer,

I am still having some trouble with the great distance calculations in 'variogram'.  Your suggestion below works, but the distances are not correct (at least, not in kilometers, meters, or miles).  I do not have proj.4 or gdal libraries installed, nor do I have the R packages proj4 or rgdal.  It seems like I should not need them, as I am not doing a projection.  Given that I am setting the 'proj4string' attribute in order to achieve a great cicle distance calculation, though, I wonder if not having those packages installed is a problem.

An example (dump output for foo is below):
z        lon      lat
1 -8.2920352  -68.74028 45.20407
2  0.3962574 -157.40894 70.46961
3 -5.3976371  -89.97919 46.08268
dist    gamma dir.hor dir.ver   id left right
1 9880.046 37.74321       0       0 var1    2     1
2 2366.200  4.18877       0       0 var1    3     1

The distance from 1 to 2 is 5299 km, and from 3 to 1 is 1650 km.  I'm not sure what the 9880.046 and 2366.200 represent.  The ratio of the variogram$dist values to the correct distances in km are not the same, so those values cannot both be correct distances in any units.

Perhaps I am missing a package that gstat needs?

Many thanks for your help.

Cheers,
Tim

=======
foo <-
structure(list(z = c(-8.29203519866722, 0.396257381218808, -5.39763713302683), lon = c(-68.740278, -157.408944, -89.97919), lat = c(45.20407,70.469611, 46.08268)), .Names = c("z", "lon", "lat"), class = "data.frame", row.names = c(NA,3L))
=======
On Wed, Apr 2008, 30 at 07:42:36AM +0200, Edzer Pebesma wrote: