How to extract data from PRISM raster for a given spatial point in R
I have a data set consisting of points with lat and long (My whole data set consists of nearly 12500 points). I want to get the daily tmin, tmax, and ppt values for these points from the PRISM rasters for the years 1981-2015.
Suppose I have only 5 data points and I want to get daily tmin and tmax for 1991-01-01 to 1991-01-31. This is what I’ve done in R. First load the required libraries
and download PRISM data.
After downloading we can plot PRISM data easily. For example for 1991-01-01 the tmax looks like as follows.
We can stack up the raster files together to get a raster stack. With lots of raster files.
Now we convert our point into a spatial points data frame. We should be careful about projections. First extract projection from raster stack and then convert points to spatial points data frame.
After adding projection to our spatial points data frame, now we can extract values from raster stack for our points with the following code.