Skip to contents

Conversion methods from mesh related objects to sfc

Usage

fm_as_sfc(x, ...)

# S3 method for class 'fm_mesh_2d'
fm_as_sfc(x, ..., format = NULL, multi = FALSE)

# S3 method for class 'fm_segm'
fm_as_sfc(x, ..., multi = FALSE)

# S3 method for class 'sfc'
fm_as_sfc(x, ...)

# S3 method for class 'sf'
fm_as_sfc(x, ...)

# S3 method for class 'inla.mesh'
fm_as_sfc(x, ...)

# S3 method for class 'inla.mesh.segment'
fm_as_sfc(x, ..., multi = FALSE)

Arguments

x

An object to be coerced/transformed/converted into another class

...

Arguments passed on to other methods

format

One of "mesh", "int", "bnd", or "loc". Default "mesh".

multi

logical; if TRUE, attempt to a sfc_MULTIPOLYGON/LINESTRING/POINT, otherwise a set of sfc_POLYGON/LINESTRING/POINT. Default FALSE

Value

  • fm_as_sfc: An sfc_MULTIPOLYGON/LINESTRING/POINT or sfc_POLYGON/LINESTRING/POINT object

Methods (by class)

  • fm_as_sfc(fm_mesh_2d): [Experimental]

  • fm_as_sfc(fm_segm): [Experimental]

  • fm_as_sfc(inla.mesh): [Deprecated] since inla.mesh is deprecated. See fm_as_sfc.fm_mesh_2d instead.

  • fm_as_sfc(inla.mesh.segment): [Deprecated] since inla.mesh.segment is deprecated. See fm_as_sfc.fm_segm instead.

See also

Examples

fm_as_sfc(fmexample$mesh)
#> Geometry set for 527 features 
#> Geometry type: POLYGON
#> Dimension:     XYZ
#> Bounding box:  xmin: -5.331027 ymin: -3.998161 xmax: 4.061656 ymax: 5.415609
#> z_range:       zmin: 0 zmax: 0
#> CRS:           NA
#> First 5 geometries:
#> POLYGON Z ((1.603919 0.1315077 0, 1.477037 0.36...
#> POLYGON Z ((1.929231 -0.2412966 0, 1.426833 -0....
#> POLYGON Z ((0.7169789 -1.03035 0, 0.3472101 -0....
#> POLYGON Z ((-2.348761 -0.5948482 0, -2.384393 -...
#> POLYGON Z ((-3.269508 0.4471134 0, -3.012816 0....
fm_as_sfc(fmexample$mesh, multi = TRUE)
#> Geometry set for 1 feature 
#> Geometry type: MULTIPOLYGON
#> Dimension:     XYZ
#> Bounding box:  xmin: -5.331027 ymin: -3.998161 xmax: 4.061656 ymax: 5.415609
#> z_range:       zmin: 0 zmax: 0
#> CRS:           NA
#> MULTIPOLYGON Z (((1.603919 0.1315077 0, 1.47703...
fm_as_sfc(fmexample$mesh, format = "loc")
#> Geometry set for 279 features 
#> Geometry type: POINT
#> Dimension:     XYZ
#> Bounding box:  xmin: -5.331027 ymin: -3.998161 xmax: 4.061656 ymax: 5.415609
#> CRS:           NA
#> First 5 geometries:
#> POINT Z (-4.991262 1.478543 0)
#> POINT Z (-5.287832 0.6496857 0)
#> POINT Z (-5.331027 -0.2295705 0)
#> POINT Z (-5.08812 -1.151174 0)
#> POINT Z (-4.710559 -1.781097 0)

# Boundary edge conversion currently only supports (multi)linestring output,
# and does not convert to polygons.
suppressWarnings(
  fm_as_sfc(fmexample$mesh, format = "bnd")
)
#> Geometry set for 1 feature 
#> Geometry type: LINESTRING
#> Dimension:     XYZ
#> Bounding box:  xmin: -5.331027 ymin: -3.998161 xmax: 4.061656 ymax: 5.415609
#> z_range:       zmin: 0 zmax: 0
#> CRS:           NA
#> LINESTRING Z (-4.991262 1.478543 0, -5.287832 0...