# make a polygon
x <- '{ "type": "Polygon",
"coordinates": [
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ]
]
}'
(y <- polygon(x))
# add bbox - without an input, we figure out the 2D bbox for you
y %>% feature() %>% bbox_add()
## 2D bbox
y %>% feature() %>% bbox_add(c(100.0, -10.0, 105.0, 10.0))
## 3D bbox
y %>% feature() %>% bbox_add(c(100.0, -10.0, 3, 105.0, 10.0, 17))
# get bounding box
z <- y %>% feature() %>% bbox_add()
bbox_get(z)
## returns NULL if no bounding box
bbox_get(x)
Run the code above in your browser using DataLab