convert2PolySet: Convert object to PolySet data

View source: R/convert2PolySet.R

convert2PolySetR Documentation

Convert object to PolySet data

Description

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

Usage

convert2PolySet(x, n_preallocate)

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

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

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

Arguments

x

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

n_preallocate

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.

Value

PBSmapping::PolySet() object.

Note

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.

Examples

## Not run: 
# generate sf object
sim_pus <- sim.pus(225L)

# convert to PolySet
x <- convert2PolySet(sim_pus)

## End(Not run)

paleo13/rapr documentation built on Feb. 12, 2024, 3:27 a.m.