[R-sig-Geo] Incorrect area coming from raster

Alex Fitz afitz at email.wm.edu
Thu Jun 9 22:16:50 CEST 2016


Hi All,

Currently I am using a raster of the gridded world population (GWPv4) to calculate density in Nigeria.  I also have the Nigeria shapefiles from GADM.  I am having an issue with the area’s that are being calculated because they are slightly off for each state/lga in Nigeria.  The approach I am taking is the following code:

pop_world_2005 is my raster the the population of the entire world
states is my shapefile containing the state boundaries

state_crop_05 <- crop(pop_world_2005, states, df = FALSE)
area_05 <- raster::area(state_crop_05)
state_area_05 <- extract(area_05, states, df = TRUE)


I think aggregated the data from my extract to check the area’s again known area’s and they seemed to be slightly incorrect with some much more incorrect than others. Here’s the code I used to join the names with the area based on their state ID.

state_area_totals_15 <- aggregate(. ~ ID, state_area_15, sum)
state_df <- as.data.frame(states)
state_names_area <- left_join(x = state_df, y = state_area_totals_15, by = c("ID" = "ID"))



I’m wondering if the shapefiles I downloaded from GADM could be the issue (Different version than those used in GWPv4.  When I some the total population of the country it appears to be correct/very close to correct so it seems to be incorrectly assigning the values to certain states.  Any help would be appreciated in figuring out where the issue is coming from.

Thanks so much,
Alex Fitz


More information about the R-sig-Geo mailing list