问题 Actually I try to calculate the major pixel values from a raster with a SpatialPolygonsDataFrame. Here is some code I found which might lead in the right direction: library(raster) # Create interger class raster r <- raster(ncol=36, nrow=18) r[] <- round(runif(ncell(r),1,10),digits=0) r[]<-as.integer(r[]) # Create two polygons cds1 <- rbind(c(-180,-20), c(-160,5), c(-60, 0), c(-160,-60), c(-180,-20)) cds2 <- rbind(c(80,0), c(100,60), c(120,0), c(120,-55), c(80,0)) polys <-