Hi @albertuna, a fully reproducible example would help us identify the issue
If that's not possible, we'll need to know what packages the spplot() and writeRaster() functions belong to.
spplot()
writeRaster()