I have a raster file with gridded population

class       : RasterLayer 
dimensions  : 132, 140, 18480  (nrow, ncol, ncell)
resolution  : 699, 931  (x, y)
extent      : 2248290, 2346150, 4771604, 4894496  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=15 +ellps=GRS80 +datum=NAD83 +units=m +no_defs 
data source : in memory
names       : gpw.v4.population.count.2015.country.totals_2015_USA 
values      : -7.127474, 5090.825  (min, max)

and I have point data

class       : SpatialPointsDataFrame 
features    : 3350 
extent      : 2259569, 2330188, 4782506, 4884012  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=15 +ellps=GRS80 +datum=NAD83 +units=m +no_defs 
variables   : 4
names       : Annual_PM25_USGrid_2015_t,       Lon,      Lat,       SiteCode 
min values  :                  3.423296, -71.12231, 41.15096,   212040868642 
max values  :                 13.396204, -71.85846, 42.01835, NWPR1NOS-NWLON 

I want to extract the population in those points within a 1kmx 1km resolution (both the raster and the points are 1kmX1km grid cells, but they are not overlap)

I used the extract function in the raster library

population_26 <- extract(raster26,
                            buffer=500, # 500m radius
                            sp = TRUE,

Is that correct? I get not reasonable numbers (too low) when I sum up all the gridded population

  • But, you used mean function. If you want to extract population, use sum as function – aldo_tapia May 14 '19 at 15:12
  • The cell resolution of your raster is c(699, 931), which is questionable in itself, so a buffer=500 argument makes no sense here as it is smaller that either cell dimension so you are functionally taking the mean/sum of a single cell. I believe that the resolution of the raster was meant to be 1000m but was not specified during projection. You should likely revisit and fix this issue. – Jeffrey Evans May 14 '19 at 17:49
  • @JeffreyEvans Thank you for your comment. You suggest to change to buffer=1000? – Alina May 15 '19 at 16:26
  • If PM25_p26 is a raster, you could use resample population density to that raster. (and it is odd that you have negative population counts). – Robert Hijmans May 16 '19 at 0:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.