These functions return the non-coordinate information of a geometry and/or vector. They do not parse an entire geometry/vector and are intended to be very fast even for large vectors.

wk_meta(handleable, ...)

# Default S3 method
wk_meta(handleable, ...)

wk_vector_meta(handleable, ...)

# Default S3 method
wk_vector_meta(handleable, ...)

wk_meta_handler()

wk_vector_meta_handler()

wk_geometry_type_label(geometry_type)

wk_geometry_type(geometry_type_label)

Arguments

handleable

A geometry vector (e.g., wkb(), wkt(), xy(), rct(), or sf::st_sfc()) for which wk_handle() is defined.

...

Passed to the wk_handle() method.

geometry_type

An integer code for the geometry type. These integers follow the WKB specification (e.g., 1 for point, 7 for geometrycollection).

geometry_type_label

A character vector of (lowercase) geometry type labels as would be found in WKT (e.g., point, geometrycollection).

Value

A data.frame with columns:

  • geometry_type: An integer identifying the geometry type. A value of 0 indicates that the types of geometry in the vector are not known without parsing the entire vector.

  • size: For points and linestrings, the number of coordinates; for polygons, the number of rings; for collections, the number of child geometries. A value of zero indicates an EMPTY geometry. A value of NA means this value is unknown without parsing the entire geometry.

  • has_z: TRUE if coordinates contain a Z value. A value of NA means this value is unknown without parsing the entire vector.

  • has_m: TRUE if coordinates contain an M value. A value of NA means this value is unknown without parsing the entire vector.

  • srid: An integer identifying a CRS or NA if this value was not provided.

  • precision: A grid size or 0.0 if a grid size was not provided. Note that coordinate values may not have been rounded; the grid size only refers to the level of detail with which they should be interpreted.

  • is_empty: TRUE if there is at least one non-empty coordinate. For the purposes of this value, a non-empty coordinate is one that contains at least one value that is not NA or NaN.

Examples

wk_vector_meta(as_wkt("LINESTRING (0 0, 1 1)"))
#>   geometry_type size has_z has_m
#> 1             0    1    NA    NA
wk_meta(as_wkt("LINESTRING (0 0, 1 1)"))
#>   geometry_type size has_z has_m srid precision is_empty
#> 1             2   NA FALSE FALSE   NA         0    FALSE
wk_meta(as_wkb("LINESTRING (0 0, 1 1)"))
#>   geometry_type size has_z has_m srid precision is_empty
#> 1             2    2 FALSE FALSE   NA         0    FALSE

wk_geometry_type_label(1:7)
#> [1] "point"              "linestring"         "polygon"           
#> [4] "multipoint"         "multilinestring"    "multipolygon"      
#> [7] "geometrycollection"
wk_geometry_type(c("point", "geometrycollection"))
#> [1] 1 7