Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New construction policy #29

Closed
FelipeBrusse opened this issue Nov 26, 2021 · 1 comment
Closed

New construction policy #29

FelipeBrusse opened this issue Nov 26, 2021 · 1 comment

Comments

@FelipeBrusse
Copy link

In this issue, I developed the inclusion of the Convex hull construction policy in the spa_creator function of the fsr package, according to the source code below and according to the paper A Systematic Approach to Creating Fuzzy Region Objects from Real Spatial Data Sets.

 convex_hull <- function(fsp, M, d){
  result_classes <- list(ncol(fsp) - 3)
  cls <- colnames(fsp)[-c(1:3)]
  for(k in 4:ncol(fsp)){  
    
    result_classes[[k-3]] <- create_empty_pgeometry("PLATEAUREGION")
    j <- 1
    for (i in M){
      res <- filter(fsp, fsp[,k] > 0 & (abs(fsp[,k] - i) <= d))
      
      j <- j+1
      pts <- st_as_sf(res, coords = c(1, 2))
      ch <- st_convex_hull(do.call(c, st_geometry(pts)))
      if(inherits(ch, c("POLYGON", "MULTIPOLYGON"))){
        comp <- component_from_sfg(ch, i)
        pregion <- create_pgeometry(list(comp), "PLATEAUREGION")
        result_classes[[k-3]] <- spa_union(result_classes[[k-3]], pregion)
      }
    }
    
    pgeoms <- tibble(class = cls, pgeometry = result_classes)
    
  }
   
    return(pgeoms)
  
}

The documentation needs to be produced and the function needs to be integrated into the spa_creator.

@accarniel
Copy link
Owner

Thank you for your contribution. The inclusion of this construction policy will make the spa_creator function compatible with the mentioned article. We have adapted this function and incorporated it into fsr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants