I have uploaded a raster image (.tif) into R and it seems to have loaded fine, however I cannot use any functions with it. Library calls, and example code posted below.
[adding text here because stack exchange won't let me post without it but I don't have any more relevant info to add]
library(sp)
library(ggplot2)
library(raster)
# image
site <- raster("C:/Users/ichth/OneDrive/Documents/Restoration_Implementation/Design_Project/Site_Raster.tif")
> site
class : RasterLayer
band : 1 (of 3 bands)
dimensions : 3597, 907, 3262479 (nrow, ncol, ncell)
resolution : 0.5, 0.5 (x, y)
extent : 958324.5, 958778, 761774.5, 763573 (xmin, xmax, ymin, ymax)
crs : +proj=tmerc +lat_0=24.3333333333333 +lon_0=-81 +k=0.999941177 +x_0=200000.0001016 +y_0=0 +datum=NAD83 +units=us-ft +no_defs
source : Site_Raster.tif
names : Site_Raster_1
values : 3, 221 (min, max)
> total_area <- cellStats(site, sum)
Error in .local(x, ..., value) : unused argument (warn = FALSE)
> plot(site)
Error in .local(x, ..., value) : unused argument (warn = FALSE)
> hist(site)
Error in .local(x, ..., value) : unused argument (warn = FALSE)
> traceback()
13: `crs<-`(`*tmp*`, warn = FALSE, value = prj)
12: `crs<-`(`*tmp*`, warn = FALSE, value = prj)
11: .fromRasterLayerBrick(from)
10: asMethod(object)
9: methods::as(x, "SpatRaster")
8: rast(object)
7: rast(object)
6: .readRasterLayerValues(object, 1, object@nrows)
5: readAll(x)
4: readAll(x)
3: .local(x, stat, ...)
2: cellStats(site, sum)
1: cellStats(site, sum)
> sessionInfo()
R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22621)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8
[3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C
[5] LC_TIME=English_United States.utf8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggplot2_3.4.2 raster_3.6-20 sp_1.5-1
loaded via a namespace (and not attached):
[1] Rcpp_1.0.9 rstudioapi_0.14 magrittr_2.0.3 tidyselect_1.2.0 munsell_0.5.0
[6] colorspace_2.0-3 lattice_0.20-45 R6_2.5.1 rlang_1.1.0 fansi_1.0.3
[11] dplyr_1.0.10 tools_4.2.1 rgdal_1.6-2 grid_4.2.1 gtable_0.3.1
[16] utf8_1.2.2 terra_1.6-41 cli_3.4.1 withr_2.5.0 tibble_3.1.8
[21] lifecycle_1.0.3 vctrs_0.5.1 codetools_0.2-18 glue_1.6.2 compiler_4.2.1
[26] pillar_1.8.1 generics_0.1.3 scales_1.2.1 pkgconfig_2.0.3
>
From traceback the error comes from the crs<-
function. Your version of pkg:terra
is out of date. You should update it. My version is terra_1.7-23 and I am unable to reproduce the error. The help page for the current version of terra
::crs<-
says "warn" is a named parameter with a default of FALSE
.