It would be useful to include a description of how to set a new bounding box in the documentation for st_bbox - how would you normally do this? Could we link to the function to do so in the documentation?
I don't think you can.
Ah, ok that works! Seems like something I remember doing, but maybe that was in sp before. Is it something that makes sense to added to sf? Something like st_bbox<-?
sp had a bbox<-. sf keeps track of bounding boxes, so they should be OK. Why would you want to set it to another value?
I think to make sure no features get cropped, which is what happens in base plotting when you're plotting something with a smaller bounding box before you plot something with a larger bounding box.
Of course, you can just plot them in the other order to solve that issue, or use a different plotting package 馃槂 But it struck me that maybe you'd want the option of setting a new bounding box for the data with the smaller geographical extent...
If plotting is the issue, I would like to try to solve it there. Maybe we can add a bbox argument to plot that takes a bbox object and uses it to set xlim and ylim?
Wrt. BBOX, see also the discussion at the foot of: https://lists.osgeo.org/pipermail/gdal-dev/2019-January/049651.html.
I think that discussion refers to the BBOX that come with CRS, to point out where they are valid/useful. sf has no access to that, but it would be cool to have it, and do something with it.
sphad abbox<-.sfkeeps track of bounding boxes, so they should be OK. Why would you want to set it to another value?
Is this true? For example, if you replace the coordinates of a sf polygon object, the 'bbox' field is not recalculated. e.g.:
sf_poly[[1]][[1]][[1]] <- new_coords
I'm having some trouble with this.
If you are comfortable doing that, you should also be comfortable using @tim-salabim 's suggestion to update the bounding box accordingly.
You're right, thanks. I should have been more thorough reading back.
Most helpful comment
If plotting is the issue, I would like to try to solve it there. Maybe we can add a bbox argument to plot that takes a bbox object and uses it to set xlim and ylim?