Question Details

No question body available.

Tags

r multidimensional-array r-stars

Answers (1)

May 26, 2026 Score: 1 Rep: 8,763 Quality: Low Completeness: 80%

It's a bug (?) with GDAL and how it appears to be handling NAs. Note that the number of errors returned using a matrix (36 with set.seed(42)) corresponds to the number of NAs in the successful result below.

It's not isolated to just using a matrix object in stextract(), or R. See this GDAL GitHub issue, and this stars GitHub issue.

This error can be avoided by using an sf object instead of a matrix. Although results will be returned, as with this stars dev comment, you will still see two (harmless?) error messages. In your case, this is because class(bcsd
obs) is "starsproxy"/"stars" object.

Also, whilst acknowledging that bcsd
ob is being used for an MRE, for the sake of completeness I'll point out that bcsdobs has no CRS. This is generally sub-optimal when working with spatial data.

To account for these issues, you can optionally convert bcsd
obs to a "stars"- only object and assign a CRS to bcsdobs prior to running stextract():

library(stars)

set.seed(42) # For reproducibility

Assin CRS (assumed to be WGS84/EPSG:4326, you'll need to double-check)

stcrs(bcsdobs)