This function converts sf::st_sf() and sp::SpatialPolygonsDataFrame() objects to PBSmapping::PolySet() objects.

convert2PolySet(x, n_preallocate)

# S3 method for SpatialPolygonsDataFrame
convert2PolySet(x, n_preallocate = 10000L)

# S3 method for SpatialPolygons
convert2PolySet(x, n_preallocate = 10000L)

# S3 method for sf
convert2PolySet(x, n_preallocate = 10000L)



sf::st_sf(), sp::SpatialPolygons() or sp::SpatialPolygonsDataFrame() object.


integer How much memory should be preallocated for processing? Ideally, this number should equal the number of vertices in the sp::SpatialPolygons() object. If data processing is taking too long consider increasing this value.


PBSmapping::PolySet() object.


Be aware that this function is designed to be as fast as possible, but as a result it depends on C++ code and if used inappropriately this function will crash R.

See also

For a slower, more stable equivalent see maptools::SpatialPolygons2PolySet.


# \dontrun{
# generate sf object
sim_pus <- sim.pus(225L)

# convert to PolySet
x <- convert2PolySet(sim_pus)
# }