[R-sig-Geo] nearest neighbour using distance in metres

Matteo Mattiuzzi matteo.mattiuzzi at boku.ac.at
Thu May 16 15:55:59 CEST 2013


Dear Ross,

Euclidean Distance is not an units, it is a type of distance measurement an it is always in input units!
The Euclidean Distance is the length of a rope between your hands that you hold strained, but see here: http://en.wikipedia.org/wiki/Euclidean_distance


nndist(xySpatialTransformed at coords)


and maybe it is not very meaningful to calculate nndist with something else than a planar coordinate system... or even equidistant coordinate system! (but I'm not a cartographer)


Matteo




>>> Ross Ahmed  05/16/13 3:14 PM >>>
Hi all,

Following code computes Euclidian distance from each point to it nearest
neighbour:

library(spatstat)
y <- rnorm(30, 55.65, .008)
x <- rnorm(30, -1.82, .01)
xy <- cbind(x, y)
nndist(xy)

Is it possible to use distance in metres, not Euclidian distances? Here are
same points projected:

xySpatial <- SpatialPoints(xy, proj4string= CRS("+proj=longlat +datum=WGS84
+ellps=WGS84 +towgs84=0,0,0"))
xySpatialTransformed <- spTransform(xySpatial, CRS("+proj=laea +lon_0=-1.92
+lat_0=55.7 +datum=WGS84"))

Thanks
Ross



    [[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



More information about the R-sig-Geo mailing list