Skip to content

add zbox and mbox attributes #1015

@ghost

Description

Request

If an sfc object has XYZ(M) dimensions, can you add a zbox (mbox) attribute to the object?

Example

In this contrived example I'm setting the Z to range in [0,2].

library(sf)
l <- sf::st_linestring(matrix(c(0,0,0,1,1,1,2,2,1,3,3,2), ncol =2, byrow = T))
sfc <- sf::st_sfc( l )

Can a zbox be calculated and added, so it would take the form

zbox <- c(0,2)
attr(sfc, "zbox") <- zbox

attributes(sfc)

# $class
# [1] "sfc_LINESTRING" "sfc"           
# 
# $precision
# [1] 0
# 
# $bbox
# xmin ymin xmax ymax 
# 0    0    3    3 
# 
# $crs
# Coordinate Reference System: NA
# 
# $n_empty
# [1] 0
# 
# $zbox
# minz maxz 
# 0    2

Use case

I'm starting to add a lot of elevation and time animations into madpeck, so it would be useful to have the ranges of these values easily accessible so they can be read directly, rather than calculated on-the-fly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions