Displaying 4 results from an estimated 4 matches for "species_input".
2024 Apr 18
2
Import multiple tif raster
...ar community
Dear Ivan
Thanks a lot. The code works now. Solution: direct and full path to the .tif files.
I confused back and forward slash
#first import all files in a single folder as a list
rastlist <- list.files(path = "C:/Users/Sibylle St?ckli/Desktop/NCCS_Impacts_Lot2_2022/InVEST/Species_Input/valpar_bee_presence", pattern='.tif$', all.files= T, full.names= T)
At the end I got a warning
#to run a function on an individual raster e.g., plot
> boxplot(allrasters[[1]])
>
> p<-boxplot(allrasters[[1]])
Warning message:
In .local(x, ...) : taking a sample of 1e+05 c...
2024 Apr 18
1
Import multiple tif raster
...t.
I tried now to provide the full path. However probably the "?" in the path produces the error, would that be possible?
> #first import all files in a single folder as a list
> rastlist <- list.files(path = "C:\Users\Sibylle St?ckli\Desktop\NCCS_Impacts_Lot2_2022\InVEST\Species_Input\valpar_bee_presence", pattern='.tif$', all.files= T, full.names= T)
Error: '\U' used without hex digits in character string (<input>:1:35)
Kind regards
Sibylle
-----Original Message-----
From: Ivan Krylov <ikrylov at disroot.org>
Sent: Thursday, April 18, 2024 2:...
2024 Apr 18
1
Import multiple tif raster
...e number of imported .tif files?
Kind regards
Sibylle
> library(terra)
> library(raster)
> getwd()
[1] "C:/Users/Sibylle St?ckli/Desktop"
>
> #first import all files in a single folder as a list
> rastlist <- list.files(path =
"/NCCS_Impacts_Lot2_2022/InVEST/Species_Input/bee_presence",
pattern='.tif$', all.files= T, full.names= T)
>
> #import all raster files in folder using lapply
> allrasters <- lapply(rastlist, raster)
>
> #to check the index numbers of all imported raster list elements
> allrasters
list()
>
> #call sin...
2024 Apr 18
1
Import multiple tif raster
? Thu, 18 Apr 2024 11:08:33 +0200
SIBYLLE ST?CKLI via R-help <r-help at r-project.org> ?????:
> > #to check the index numbers of all imported raster list elements
> > allrasters
> list()
> >
> > #call single raster element
> > allrasters[[1]]
> Error in allrasters[[1]] : subscript out of bounds
`allrasters` is an empty list, so it doesn't have a