I'm running the following code to cycle through individual polygons (surface water basins) in a shapefile and averaging data from a netcdf:
# Extracting basin ID values basinid<-basin_latlong$value for (i in basinid) { #individual basin extraction dummybasin<-basin_latlong[basin_latlong$cat==i,] # Extracted basin extent dummyextent<-extent(dummybasin) # Extract trmm around basin for refinement trmm_sub<-crop(trmm,dummyextent,snap="out") # Refining resolution by a factor of 10 trmm_sub<-disaggregate(trmm_sub,fact=10) # Rasterizing basin to use as a mask mask<-rasterize(dummybasin,trmm_sub) # using mask to restrict data to the basin area. basintrmm<-mask(trmm_sub,mask=mask) # Computing the average timeseries on the basin basin_trmm_aveTS<-cellStats(basintrmm,mean) } I get the following error: OGR data source with driver: ESRI Shapefile Source: "/home/shared/saudi", layer: "Jizan_South_subbasin_poly_clean" with 42 features and 5 fields Feature type: wkbPolygon with 2 dimensions Found 1 region(s) and 1 polygon(s) Found 1 region(s) and 1 polygon(s) Found 1 region(s) and 1 polygon(s) Found 1 region(s) and 1 polygon(s) Found 1 region(s) and 1 polygon(s) Found 1 region(s) and 1 polygon(s) Found 1 region(s) and 1 polygon(s) Found 1 region(s) and 1 polygon(s) Found 1 region(s) and 1 polygon(s) Found 1 region(s) and 1 polygon(s) Found 1 region(s) and 1 polygon(s) Found 1 region(s) and 1 polygon(s) Found 1 region(s) and 1 polygon(s) Found 1 region(s) and 1 polygon(s) Found 1 region(s) and 1 polygon(s) Found 1 region(s) and 1 polygon(s) Found 1 region(s) and 1 polygon(s) Found 1 region(s) and 1 polygon(s) Error in d[, alyrs, drop = FALSE] : incorrect number of dimensions Basically it works for a while and err on a specific basin with basinids 16, 34, 46,... thanks [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo