R/TopoSUB_getCluster4verification.R

Defines functions TopoSUB_getCluster4verification

Documented in TopoSUB_getCluster4verification

# function to retrieve representative cluster centroid for each obs station
TopoSUB_getCluster4verification <- function(wpath)
{
  # reading obs station meta data
  meta_data <- read.csv(file.path(wpath,"obs/meta.csv"))
  
  # reading listpoint data
  listpoint_data <- read.csv(file.path(wpath,"listpoints.txt"))
  
  # reading landform raster data 
  files_wpath <- dir(wpath)
  
  landform_asc <- files_wpath[grepl("landform", files_wpath)]
  landform_rst <- raster(file.path(wpath,landform_asc))
  
  # get cluster centroid representing obs data
  #? how to get representative cluster centroid
  meta_data$cluster_centroids <- raster::extract(landform_rst, meta_data[,c("x","y")])
  
  # join listpoint data
  meta_data <- merge.data.frame(meta_data, listpoint_data, by.x = "cluster_centroids", by.y = "id")
  meta_data <- meta_data[order(meta_data$OID),]
  
  return(meta_data)
}
JBrenn/TopoSUB documentation built on May 7, 2019, 7:39 a.m.