I am trying to calculate the raster breadth of multiple species raster files (Maxent output) and doing this using a for loop. Every loop where the breadth is calculated I also intended for the result to be saved as a csv file, but I'm running into issues.
This is the code that I had so far:
data <- read.csv("orchid_occurrences.csv", sep = ";", stringsAsFactors = FALSE)
spp_to_model <- unique(data$species)
orchid <- paste0("./orchid_data/",spp_to_model,"_avg.asc")
for(spp_to_model in orchid){
spp_raster <- raster(spp_to_model)
spp_breadth <- raster.breadth(spp_raster)
write.table(spp_breadth, spp_to_model,"_breadth.csv", row.names = FALSE)
}
I adapted this a little bit to fit the sample of occurrence data and raster files that I shared here: https://drive.google.com/file/d/1oA78dnZBSd9B_9EJuaWxg2isK-9lfQ5Q/view?usp=sharing
Thanks in advance!