Displaying 3 results from an estimated 3 matches for "spdistsn1".
2009 Nov 18
0
Effective measurement of point-polygon distance
...80,85,87,90,85,80),
c(10,15,17,15,10,10)
))))))
w2 <- SpatialLines(list(Lines(list(Line(cbind(
c(65,67,76,68,65),
c(30,29,24,22,30)
))))))
# Test points:
x = c(5, 7, 35, 28)
y = c(60, 70, 90, 85)
xy <- SpatialPoints(cbind(y,x))
distance <- rep(NA, 4)
for (i in 1:4){distance[i] <- min(spDistsN1(coordinates(spsample((w1), n=50,
type = "regular")), coordinates(xy[i,]), longlat=T))}
for (i in 1:4){distance[i] <- min(spDistsN1(coordinates(spsample((w2), n=50,
type = "regular")), coordinates(xy[i,]), longlat=T))}
distance
# What I need, is a for-loop (or something simil...
2007 Aug 16
1
Question on output of vectors from a for loop into a matrix
...s in a vector (the for
loop). I can get them all to print and can save each individually to a
file, but I cannot get them to be bound into a matrix.
Here is the code that I have tried:
m<-length(Day.1.flower.coords$x) #31 grid points
output.matix<-matrix(0.0,m,m)
for(i in 1:m){
dist<-spDistsN1(Day.1.coords.matrix, Day.1.coords.matrix[i,])
dist<-as.vector(dist)
output.matrix[i,]<-dist
print(dist)}
The error message that I get is:
Error in output.matrix[i,] <- dist : incorrect number of subscripts on matrix
Thanks for your help.
Ryan
~~~~~~~~~~~~~~~~~~
Ryan D. Briscoe...
2010 Nov 19
2
Calculating distance between longitude,latitude of 2 points
Hi all,
I would like to know a way of calculating the distance between 2 points when
I already have the longitude and latitude of the points.
For example :
Point 1 : 52? 9'54.00"N 4?25'8.40"E
Point 2 : 52?27'46.80"N 4?33'18.00"E
Distance between point 1 and point in km ....
Is there any functions already available for this ?
Any help will be much