On Fri, Apr 6, 2012 at 10:26 PM, Tammy Wilson <t...@aggiemail.usu.edu> wrote: > Trigonometry will work for projected coordinate systems like UTM: > > Try this: > # number of points > n = 30 > > # reference location > ref.pt = cbind(1,2) > > # generate some random directions > # This can be your list of your bearings converted to radians > dir <- runif(n,0,2*pi ) > > # generate some random distances > # This can be your list of distances in map units (e.g. m) > dist <- runif(n,0.5,10) > > #empty matrix for coordinates > coords.mat = cbind(rep(0,n),rep(0,n)) > > #using trigonometry to calculate object location > for (i in 1:n){ > coords.mat[i,1] = ref.pt[1]+(sin(dir[i])*dist[i]) > coords.mat[i,2] = ref.pt[2]+(cos(dir[i])*dist[i]) > } > plot (coords.mat) > points(ref.pt,col=2) > > Best, > Tammy
Thank you for the code, Tammy! Meanwhile Michael Summer pointed my attention the the geosphere package and the destPoint() function seems to do exactly what I was searching for. Cheers, Ivailo -- UBUNTU: a person is a person through other persons. _______________________________________________ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology