R: sfg multipolygon

sfg_multipolygon {sfheaders} | R Documentation

## sfg multipolygon

### Description

constructs sfg MULTIPOLYGON object

### Usage

    sfg_multipolygon(
      obj,
      x = NULL,
      y = NULL,
      z = NULL,
      m = NULL,
      polygon_id = NULL,
      linestring_id = NULL,
      close = TRUE
    )

### Arguments

`obj` | matrix or data.frame
`x` | x geometry column
`y` | y geometry column
`z` | z geometry column
`m` | m geometry column
`polygon_id` | column of ids for polygons (within the multipolygon)
`linestring_id` | column of ids for lines (within polygons)
`close` | logical indicating whether polygons should be closed. If `TRUE`, all polygons will be checked and force closed if possible

### Value

`sfg` object of MULTIPOLYGON geometry

### Examples

    df <- data.frame(
      polygon_id = c(rep(1, 5), rep(2, 10))
      , line_id = c(rep(1, 10), rep(2, 5))
      , x = c(0,0,1,1,0,2,2,5,5,2,3,3,4,4,3)
      , y = c(0,1,1,0,0,2,5,5,2,2,3,4,4,3,3)
      , z = c(1)
      , m = c(1)
    )

    m <- as.matrix( df )

    sfg_multipolygon( df[, c("x","y") ] )

    sfg_multipolygon(
      df, x = "x", y = "y", polygon_id = "polygon_id", linestring_id = "line_id"
      )
    sfg_multipolygon(
      df, x = "x", y = "y", z = "z", polygon_id = "polygon_id", linestring_id = "line_id"
      )
    sfg_multipolygon(
      df, x = "x", y = "y", z = "z", m = "m", polygon_id = "polygon_id", linestring_id = "line_id"
      )

    sfg_multipolygon( m[, c("x","y") ] )

    sfg_multipolygon(
      m, x = "x", y = "y", polygon_id = "polygon_id", linestring_id = "line_id"
      )
    sfg_multipolygon(
      m, x = "x", y = "y", z = "z", polygon_id = "polygon_id", linestring_id = "line_id"
      )
    sfg_multipolygon(
      m, x = "x", y = "y", z = "z", m = "m", polygon_id = "polygon_id", linestring_id = "line_id"
      )

[Package sfheaders version 0.2.2 Index]