Is there any specific reason why st_as_sf and st_transform do not have methods for bboxes?
It would be nice if st_as_sf(bbox) returned a sf object with 1 feature: the respective (rectangular) polygon.
Also, st_transform(bbox, crs) could return the equivalent of st_bbox(st_transform(as_as_sf(bbox), crs)).
Especially the latter could be a bit misleading to newcomers tho.
You can use st_as_sfc(bbox) which makes sense as it is a geometry only. Hence, st_bbox(st_transform(st_as_sfc(bbox), crs)) should also work.
Whoops. Makes sense.
I think that st_transform(bbox, crs) could work like st_bbox(st_transform(st_as_sfc(bbox), crs)).
@edzer , do you agree?
It could, but I still prefer the latter because it is explicit. If you'd do the former, users might be surprised that what you get is not (always) simply the transformed c(xmin,ymin) and c(xmax,ymax). Enforcing the latter gives users the opportunity to find out themselves. Implementing the former requires us also to write down such semantics of a bbox object, and requires users to read that.
Yes, I see that it could lead to some confusion. Perhaps an example in st_bbox's manual would aid in discoverability.
Most helpful comment
You can use
st_as_sfc(bbox)which makes sense as it is a geometry only. Hence,st_bbox(st_transform(st_as_sfc(bbox), crs))should also work.