stars icon indicating copy to clipboard operation
stars copied to clipboard

st_set_bbox() not persistent when applied to stars_proxy object

Open dazu89 opened this issue 1 year ago • 2 comments

I was happy to discover that read_stars supports reading any file as stars_proxy object, ~~significantly easing my memory constraints~~ (quite the contrary occured to my surprise, see #708)! However, st_bbox() when applied via st_set_bbox() to a stars_proxy does not outlast the conversion into a stars object, e.g.

library(stars)
fl = system.file("tif/L7_ETMs.tif", package = "stars")
rs = read_stars(fl, proxy = TRUE)
rs2 = rs |> 
  st_set_bbox(value = st_bbox(rs)*2) |> 
  st_as_stars()

# The two bboxes should be different, i.e. TRUE TRUE TRUE TRUE
st_bbox(rs) != st_bbox(rs2)

This entails problems for intermediate down-sampled output such as plots as well as repetitive statements after each obtained stars objects if the st_bbox of the raw data is not set correctly.

dazu89 avatar Sep 01 '24 15:09 dazu89

The help for st_set_bbox is rather short; what is it that you want to get done by using it?

edzer avatar Sep 01 '24 20:09 edzer

Thank you, @edzer, for your reply. My raster in ASCII Grid form has wrong cellsize or dx/dy values so I wanted to correct these before further processing, by manually setting the bounding box. I could work around this problem by modifying the data in place, but preferred an in memory replacement.

dazu89 avatar Sep 01 '24 22:09 dazu89