Reputation: 293
How do I loop through all rasters (TIFF) in a folder and extract values using a point shapefile which has several coordinates then have the output as a dataframe?
Upvotes: 3
Views: 1979
Reputation: 1704
library(raster)
library(rgdal)
files <- list.files(path=".", pattern="tif$", full.names=TRUE) # select all the tiff files in the directory
s <- stack(files) # stack all of them using r raster library
shp <- shapefile("points.shp") # read the point shape file
ext <- extract(s, shp) # extract the values from raster stack.
Upvotes: 4