Closed btupper closed 4 months ago
(crop1 = st_normalize(crop))
# stars object with 4 dimensions and 1 attribute
# attribute(s):
# Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
# sst [°*C] 5.58 24.9875 27.8 25.8206 28.84 30.5 5384
# dimension(s):
# from to offset delta refsys x/y
# x 1 120 270 0.25 NA [x]
# y 1 120 50 -0.25 NA [y]
# zlev 1 1 0 [m] NA NA
# time 1 1 1981-09-01 UTC NA POSIXct
(icrop = st_cells(crop1, x))
# [1] 4311 9356 3815 8319 6704 9679 5030 14098 3754 10251
icrop <= mx
# [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
crop
is a subgrid in the original raster of orig
: the offset didn't change, only the row/col offsets do. st_normalize
moves offset
and resets row/col indices to start form 1. Should this be added to the docs of st_crop
, or st_cell
?
Oooooooh! Of course! I love st_normalize
already and I haven't used it.
I think it would be great to add to the docs of st_crop
and st_cells
. I can do a PR. What do you think about adding an optional logical argument normalize
to run st_normalize
?
What do you think about adding an optional logical argument normalize to run st_normalize?
Yes, that would indeed make sense for st_crop
.
Hi,
I’m having trouble understanding the output on
st_cells()
when operating upon a cropped image. Below I crop a large image, and create a subsample of points using the cropped image. Then I runst_cells()
on each. The values of the cell indices from the cropped image are unexpected.First we read in data from the
starsdata
package.Next we create a bounding box, and crop the
orig
.Make a set of random points in the cropped domain
Compare the maximum cell index with the output of
st_cells
. Note the cells indices are less than the maximum possible cell index.And now the same for the cropped.
Whoops! They are all larger than largest possible index value. I must be missing something. Why does cropping cause
st_cells
to return erroneous values?