Subset Spatial Points for calculating Home Ranges

Viewed 11

I' trying to calaculate home ranges of birds. I have a table with Bird IDs, family ids, calender week and coordinates and i would like to calculate home ranges for a whole family (not single birds) per calender week. But I'm failling to make subsets. Can anyone help?

'data.frame':   406 obs. of  18 variables:
 $ birdId     : chr  "DoLan22_1_1" "DoLan22_1_1" "DoLan22_1_1" "DoLan22_1_1" ...
 $ Familien_ID: int  1 1 1 1 1 1 1 1 1 1 ...
 $ dateM1     : chr  "18.05.2022" "19.05.2022" "19.05.2022" "20.05.2022" ...
 $ timeM1     : chr  "15:08" "13:31" "18:39" "11:19" ...
 $ latM1      : chr  "N48.62409" "N48.62489" "N48.62414" "N48.62521" ...
 $ lonM1      : chr  "E11.20807" "E11.20754" "E11.20595" "E11.20550" ...
 $ angleM1    : int  314 288 30 97 75 351 11 315 324 312 ...
 $ dateM2     : chr  "18.05.2022" "19.05.2022" "19.05.2022" "20.05.2022" ...
 $ timeM2     : chr  "15:18" "13:41" "18:48" "12:04" ...
 $ latM2      : chr  "N48.62344" "N48.62421" "N48.62406" "N48.62392" ...
 $ lonM2      : chr  "E11.20622" "E11.20593" "E11.20753" "E11.20736" ...
 $ angleM2    : int  45 30 310 310 351 99 61 4 53 55 ...
 $ targetLat  : chr  "48.62437" "48.62508" "48.62468" "48.62526" ...
 $ targetLon  : chr  "11.20763" "11.20669" "11.20642" "11.20494" ...
 $ user       : chr  ...
 $ area       : chr  ...
 $ KW         : int  20 20 20 20 20 20 20 20 20 20 ...
 $ Alter      : int  1 2 2 3 4 4 5 5 1 2 ...
> names(daten)[names(daten)=="Familien_ID"] <- "id"
> daten$Lat<-as.numeric(daten$targetLat)
> daten$Lon<-as.numeric(daten$targetLon)
> daten.sp <- daten[,c ("id", "Lat", "Lon", "KW") ]
> coordinates(daten.sp)<-c("Lon","Lat")
> daten.sp <- SpatialPoints(daten[c("Lon", "Lat")])
> proj4string(daten.sp) = CRS("+init=epsg:4326")
> class(daten.sp)
[1] "SpatialPoints"
attr(,"package")
[1] "sp"
> KW20<-subset(daten.sp, KW=="20")
Error in subset.Spatial(daten.sp, KW == "20") : 
  subset only works for Spatial*DataFrame objects
> ```
0 Answers
Related