R/2_G_Width.R

Defines functions G_Width

######   ----    FUNCTION 2.

######   ----    NAME: G_Width
######   ----    ARGUMENTS: None
######   ----    ACTION: Measures the real width of the geometric
######   ----    COMMENTS: None

##Rationale: width = measure line formed by (max_x + min_x) + fix y

G_Width <- function(x){
  r.pol<-x
  r.pol_df<-as.vector(r.pol@polygons[[1]]@Polygons[[1]]@coords[,1])
  #measure width. Highest x - lowest x
  width <- round(max(r.pol_df)-min(r.pol_df),2)
  names(width) <- "Width"
  return(width)
}

####   ----  END FUNCTION 2
acortell3/GeomeasuRe documentation built on Dec. 18, 2021, 10:23 p.m.