I am attempting to subset and project an ecoregions shapefile from : EPA ECOREGIONS my data set is found here: SHAPEFILES and RASTER When I run this code, two major problems occur: 1) I cannot get the subset of ecoregions to plot on top of my raster file and 2) I cannot extract the values (summary information) from the subset of ecoregions from the raster. Can anyone help with this?
require (raster) raster<-raster('FG_RCP26_2050.tif') plot (raster)
ecoregions.all<- readOGR("NA_CEC_Eco_Level2.shp",layer="NA_CEC_Eco_Level2") head (ecoregions.all) plot (ecoregions.all)
#this is the subset of ecoregions that I need NA_L2<-c('5.1','5.2','5.3','8.1','8.3','8.4','8.5') #subset the ecoregion.all to just those in the northeast #this must be where the problem is ne.ecoregions = coregions.all[match(toupper(NA_L2),toupper(ecoregions.all$NA_L2CODE)),] #plot ne.ecoregions on top of raster and extract summary statistics for each ecoregion #summary statistics =distribution of values within each ecoregion plot (raster) plot (ne.ecoregions, add=T) ecoregions.raster<-mask (raster, ne.ecoregions) summary (ecoregions.raster)