I want to extract values from a raster file containing gridded population in US (spatial resolution of 1X1 km) based on points shapefile, also in US.
Both are in the projection.
Here is my code:
# The points layer USGridSite <- readRDS("USGridSite.rds") writeOGR(USGridSite, "USGridSite.shape.file", "USGridSite.shape.file", driver = "ESRI Shapefile") USGridSiteCoords<-USGridSite@coords # The raster file gridded_population<-raster("gpw-v4-population-count-adjusted-to-2015-country-totals_2015_USA_clipped.tif") # Extracting mean population from the raster gridded_population_mean <- extract(gridded_population, USGridSiteCoords, # should it be the USGridSite file? fun=mean, sp = TRUE, # create spatial object buffer = 1000) # I want 1X1 km results
It is not working, am I doing something wrong?