as_tibble.pgeometry {fsr}R Documentation

Convert a pgeometry object into tabular data (data.frame or tibble)

Description

These functions convert a pgeometry object into a tabular format, such as a tibble or data.frame object, where the components of the pgeometry object compose the rows of the table.

Usage

## S3 method for class 'pgeometry'
as_tibble(x, ...)

## S3 method for class 'pgeometry'
as.data.frame(x, ...)

Arguments

x

A pgeometry object.

...

<dynamic-dots> Unused.

Details

These functions are S3 methods for pgeometry. The as_tibble() function converts a pgeometry object into a tibble, which is a data frame with class tbl_df. This allows us to get the internal components of the pgeometry object (i.e., spatial features objects and membership degrees) as a data frame with two separate columns: (i) geometry (an sfc object) and (ii) md (membership degree). Therefore, each row of this tibble represents a component of the original pgeometry object.

It is also possible to call the S3 method as.data.frame() to convert a pgeometry object into a data.frame object.

Value

A tabular object (data.frame or tibble) with the number of rows corresponding to the number of components of the pgeometry object given as input and two columns in the format ⁠(geometry, md)⁠.

Examples

pcomp1 <- create_component("MULTIPOINT(1 2, 3 2)", 0.4)
pcomp2 <- create_component("POINT(2 1)", 0.3)
pcomp3 <- create_component("MULTIPOINT(5 1, 0 0)", 1)
ppoint <- create_pgeometry(list(pcomp1, pcomp2, pcomp3), "PLATEAUPOINT")

# Converting the pgeometry object into a tibble object
ppoint_tibble <- as_tibble(ppoint)
ppoint_tibble

# Converting it into data.frame
ppoint_df <- as.data.frame(ppoint)
ppoint_df

[Package fsr version 2.0.1 Index]