I have a stack of rasters (one per view), and then I have a data frame with lat / long columns along with the name of the view.
fls = list.files(pattern="median") s <- stack(fls) df<-c("x","y","species name")
I want to be able to just select one raster at a time so that I can use it with the extraction function. I want the selection to be based on a partial match based on the view name column. I want to do this because the raster names may not coincide with the names in the species list, there may be a mismatch in the lower / upper case, or the name of the raster layer may be longer, for example, species_name_median, or there may also be a _ instead of a space.
for(i:length(df.species name)) { result<-extract(s[[partial match to "species name[i]" ]],df.xy) }
Hope this makes sense that I just want to use one raster at a time for extraction. I can easily select one raster using s [[i]], but there is no guarantee that each view in the list has its own equivalent raster file.
source share