#' @title build a dataframe of postprob value for each point
#' @author Melody Premaillon
#'
#' @param path folder path where raster is saved
#' @param name_shape name of point shapefile
#' @param name_rast_postprob name of susceptibility raster
#'
#' @description This function takes two files : susceptibility raster and a point shapefile (can be trainning/valid or complete). One read, raster values are extracted from each point location. Finaly a df is build with unique postprob values of points set and their count.
#'
#' @return a data frame of unique postprob values and count of points
#' @export
#'
#' @import raster
#' @import rgdal
#' @import dplyr
#'
extract_shape_postprob <- function(path, name_shape, name_rast_postprob){
rastpp <- raster(paste(path, "/", name_rast_postprob, ".tif", sep=""))
postprob_shape <- readOGR(paste(path, "/", name_shape, ".shp", sep=""))
shape_df <- data.frame(POST_PROB = raster::extract(rastpp, postprob_shape))
shape_df <- shape_df %>%
filter(!is.na(POST_PROB)) %>%
group_by(POST_PROB) %>%
summarise(POINTS = n())
return(shape_df)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.