Skip to content

nearest neighbour using distance in metres

3 messages · Ross Ahmed, Matteo Mattiuzzi, Hugh Sturrock

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




_______________________________________________
R-sig-Geo mailing list
R-sig-Geo at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo