Loading the waypoints
library(mapview)
library(sf)
library(dplyr)
library(giscourse)
path<-"/home/arne"
a<-dir(path,pattern="gpx")
a<-sprintf('%s/%s',path,a)
f<-function(x){
d<-st_read(x,layer = "waypoints")
d$group<-x
d
}
d<- do.call("rbind",lapply(a,f))
## Reading layer `waypoints' from data source `/home/arne/D.gpx' using driver `GPX'
## Simple feature collection with 9 features and 23 fields
## geometry type: POINT
## dimension: XY
## bbox: xmin: -2.048178 ymin: 50.68701 xmax: -2.038586 ymax: 50.68853
## epsg (SRID): 4326
## proj4string: +proj=longlat +datum=WGS84 +no_defs
## Reading layer `waypoints' from data source `/home/arne/Group_A_Waypoints.gpx' using driver `GPX'
## Simple feature collection with 8 features and 23 fields
## geometry type: POINT
## dimension: XY
## bbox: xmin: -2.048392 ymin: 50.6872 xmax: -2.038436 ymax: 50.6887
## epsg (SRID): 4326
## proj4string: +proj=longlat +datum=WGS84 +no_defs
## Reading layer `waypoints' from data source `/home/arne/GroupB_Waypoints.gpx' using driver `GPX'
## Simple feature collection with 7 features and 23 fields
## geometry type: POINT
## dimension: XY
## bbox: xmin: -2.048389 ymin: 50.68722 xmax: -2.038567 ymax: 50.68886
## epsg (SRID): 4326
## proj4string: +proj=longlat +datum=WGS84 +no_defs
## Reading layer `waypoints' from data source `/home/arne/GroupC.gpx' using driver `GPX'
## Simple feature collection with 11 features and 23 fields
## geometry type: POINT
## dimension: XY
## bbox: xmin: -2.048479 ymin: 50.68676 xmax: -2.038719 ymax: 50.68857
## epsg (SRID): 4326
## proj4string: +proj=longlat +datum=WGS84 +no_defs
d %>% select(c("name", "group","time")) ->d
## Error in (function (classes, fdef, mtable) : unable to find an inherited method for function 'select' for signature '"sf"'
mapview(d, zcol='group',burst=TRUE, legend=FALSE) ->mp
mp@map %>% leaflet.extras::addFullscreenControl()
coords<-st_coordinates(d)
clus<-hclust(dist(coords))
plot(clus)
d$site<-as.factor(cutree(clus,2))
mapview(d, zcol='site',burst=TRUE, legend=FALSE) ->mp
mp@map %>% leaflet.extras::addFullscreenControl()