[R-sig-Geo] Speed filter vmask() in argosfilter package

Michael Sumner mdsumner at gmail.com
Thu Oct 29 02:22:28 CET 2009


Sorry all, I didn't notice I was sending RTF emails. Hopefully this
will rectify:



On Thu, Oct 29, 2009 at 12:15 PM, Michael Sumner <mdsumner at gmail.com> wrote:
> I don't see "ltr" defined in your code. Is that meant to be "tr1"
> throughout?
>
>
>
> On Thu, Oct 29, 2009 at 8:44 AM, Tim Clark <mudiver1200 at yahoo.com> wrote:
>>
>> Dear List,
>>
>> I am trying to filter animal tracking data based on speed using the
>> vmask() function in argosfilter.  However, when I check the filtered data
>> against speed that I compute in the adehabitat package it shows that the
>> filter is not working correctly.  The vmask() function requires coordinates
>> in long/lat while adehabitat requires it in UTM.  I would greatly appreciate
>> it if someone could check my work and let me know what I am doing wrong.  I
>> have included an example below using data from adehabitat.
>>
>> Thanks,
>>
>> Tim
>>
>>
>> library(argosfilter)
>> library(adehabitat)
>>
>> #Data
>> data(puechabon)
>> locs <- puechabon$locs   #Dataframe with location and date for individual
>> animal over time
>>
>> #Adehabitat package
>>  #Variables
>>    xy <- locs[,c("X","Y")]  #Locations in UTM
>>    id<- as.character(locs$Name)
>>    da <- as.character(locs$Date)
>>    da <- as.POSIXct(strptime(as.character(locs$Date),"%y%m%d"))
>>  #Create ltraj
>>    tr1 <- as.ltraj(xy,date = da, id = id)
>>
>>  #Calculate speed
>>      sp1<-lapply(ltr,function (l){l$dist/l$dt})            #Compute speed
>> in m/sec
>>  #Unlist
>>    sp2<-round(unlist(sp1,recursive = TRUE),2)
>>
>>
>> #Argosfilter package
>>    #Transform coordinates to long/lat
>>      library(rgdal)
>>      SP.utm<-data.frame(locs[,c("X")],locs[,c("Y")])
>>      SP.utm<-SpatialPoints(SP.utm,proj4string=CRS("+proj=utm +zone=31
>> +ellps=WGS84"))
>>      SP.ll<-spTransform(SP.utm, CRS("+proj=longlat +ellps=WGS84"))
>>      SP.ll<-data.frame(SP.ll)
>>      names(SP.ll)<-c("lon","lat")
>>
>>      lon<- SP.ll$lon
>>      lat<- SP.ll$lat
>>
>>    #filter by speed
>>      mfilter<-vmask(lat,lon,dtime=da,vmax=1)
>>      filtered<- locs[mfilter!=c("removed"),]
>>
>> #Adehabitat package
>>    #Create ltraj
>>    xy <- filtered[,c("X","Y")]
>>    id<- as.character(filtered$Name)
>>    da <- as.character(filtered$Date)
>>    da <- as.POSIXct(strptime(as.character(filtered$Date),"%y%m%d"))
>>    tr1 <- as.ltraj(xy,date = da, id = id)
>>
>>    #Calculate speed
>>        sp3<-lapply(ltr,function (l){l$dist/l$dt})            #Compute
>> speed in m/sec
>>      #Unlist
>>        sp4<-round(unlist(sp1,recursive = TRUE),2)
>>
>> #Check data
>>  quantile(sp2, probs = seq(.5, 1, 0.1), na.rm = TRUE)
>>  quantile(sp4, probs = seq(.5, 1, 0.1), na.rm = TRUE)
>>
>>
>>
>>
>>
>> Tim Clark
>> Department of Zoology
>> University of Hawaii
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>



More information about the R-sig-Geo mailing list