[R] Calculating distance between spatial points
nicolas.korber at bluewin.ch
Sun Aug 2 09:03:53 CEST 2009
to call each variable separately, you can coerce your sp object back to a
dataframe. The code below should to the job:
DF.utm <- as.data.frame(SP.utm)
Tim Clark wrote:
> Dear List,
> I am trying to determine the speed an animal is traveling on each leg of a
> track. My data is in longitude and latitude, so I am using the package
> rgdal to convert it into a spatial points data frame and transform it to
> UTM. I would then like to find the difference between successive
> longitudes and latitudes, find the euclidean distance between points, and
> compute the speed of the animal on each leg.
> My problem is that once I convert the lat and long into a spatial points
> data frame I can not access the lat and long individually. As far as I
> know I need to convert them in order to transform the lat and long to UTM.
> Is there a way I can call each variable separately in the sp dataframe?
> My code with example data is below. Any suggestions would be appreciated.
> Long<-c(-156.0540 ,-156.0541 ,-156.0550 ,-156.0640)
> SP<-SpatialPoints(SP,proj4string=CRS("+proj=longlat +ellps=WGS84"))
> SP.utm<-spTransform(SP, CRS("+proj=utm +zone=4 +ellps=WGS84"))
> Tim Clark
> Department of Zoology
> University of Hawaii
> R-help at r-project.org mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
View this message in context: http://www.nabble.com/Calculating-distance-between-spatial-points-tp24212875p24775433.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help