I have an .TIFF file (raster) for Latin America and .shp file (shapefile) for brazilian municipalities and I want to overlap both but I want sum all the informations that a raster have.
In my case, I have a TIFF file is about light pollution. Every point in raster represent one light information that ranging from 0-63. The shapefile have only the geometry.
In the end I want that every information in municipality return the sum (or mean) of all the raster points.
Someone knows that's possible in R software?
Many thanks
I Cannot give an example because TIFF file is too big but I sending an image
I want to overlay a map like this one, but with smaller dimensions
try this:
require(raster)
rs=raster("pathToTiff.tif")
shp=shapefile("pathToShapefile.shp")
##to get the sum of all raster values within in each administrative area:
##assuming that they are in the same CRS, if not in same CRS run this first - shp=spTransform(shp,crs(rs))
extract(rs,shp,fun=sum)