I have sf object with multipolygons which i need to convert to sp object. It does not seem to work with sf conversion functions.
I tried
library(absmapsdata)
library(sp)
library(sf)
vic_sa4<-sa42021
class(vic_sa4)
vic_sa4_sp <- as_Spatial(vic_sa4)
tmp <-as(vic_sa4, 'Spatial')
vic_sa4_sp <- sf:::as_Spatial(st_geometry(vic_sa4))
as(vic_sa4, "Spatial")
it all gives me this error - but the geometry is indeed there! how to fix this?
error in evaluating the argument 'x' in selecting a method for function 'addAttrToGeom': empty geometries are not supported by sp classes
You need to get rid of the items with empty geometry. You can test with
st_is_empty. Here's a thing with some empty geometries caused by excessive negative buffering into nothingness:Test:
Remove:
Convert: