I am trying to save .csv raster file from the data.frame but an error occurs.
library(dismo)
sp <- gbif("Neurergus ","kaiseri")
sp <- sp[sp$basisOfRecord %in% c("HUMAN_OBSERVATION", "OBSERVATION", "PRESERVED_SPECIMEN"), c("lon", "lat")]
sp$species <- 1
sp <- na.omit(sp)
writeRaster(spg, "zzz.csv")
#Error in (function (classes, fdef, mtable) :
# unable to find an inherited method for function ‘writeRaster’ for signature ‘"data.frame", "character"’
You want to write a
data.frameto a.csvfile. You should usewrite.csvfor that.writeRasteris for writing raster data.