st_cells: return the cell index corresponding to the location of a set...

st_cellsR Documentation

return the cell index corresponding to the location of a set of points

Description

return the cell index corresponding to the location of a set of points

Usage

st_cells(x, sf)

Arguments

x

object of class stars

sf

object of class sf or sfc

Examples

set.seed(1345)
st_bbox(L7_ETMs) |> 
  st_as_sfc() |> 
  st_sample(10) -> pts 
(x <- st_cells(L7_ETMs, pts))
# get the pixel values (first band only):
st_as_stars(L7_ETMs)[[1]][x]
# get pixel values for all bands:
st_as_stars(L7_ETMs) |> split() |> sapply(`[`, x)
# compare with st_extract():
st_as_stars(L7_ETMs) |> split() |> st_extract(pts)

stars documentation built on May 29, 2024, 8:59 a.m.