I’m struggling with R and terra. I have several GeoTIFF rasters (DEM, slope, aspect, etc.) that I want to use for predictions with a Random Forest model.
The problem:
When I import the rasters using terra::rast("my_raster.tif"), everything seems fine.
plot(raster) works, and I can see the image.
BUT when I try values(raster) or as.data.frame(raster), all values are NaN.
I’ve tried readAll(), crop(), mask()… nothing works.
Even small subsets return NaN values.
This happens with all my rasters, not just one.
I’ve checked:
The files are not empty (they open fine in QGIS).
CRS and extents seem normal.
File paths are correct.
I have no idea what’s going on. Is this a raster format issue, a compatibility problem with terra, or something else?
If anyone has encountered this and has a solution, I’d really appreciate it 😅.
Thanks in advance!