unable to find an inherited method for function ‘writeRaster’ for signature ‘"data.frame", "character"’

209 Views Asked by At

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"’
1

There are 1 best solutions below

0
Robert Hijmans On

You want to write a data.frame to a .csv file. You should use write.csv for that.

write.csv(spg, "zzz.csv", row.names=FALSE)

writeRaster is for writing raster data.