我正在尝试绘制一个包含 12 个生态区的图,这些生态区以 shapefile 的形式出现。举个例子:
ER_10.2<-Level.2.ecoregs[Level.2.ecoregs$NA_L2CODE=="10.2",]
> ER_10.2
class : SpatialPolygonsDataFrame
nfeatures : 26
extent : -1693158, 44930.55, -2591002, -691719.8 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 +a=6370997 +b=6370997 +units=m +no_defs
nvariables : 8
names : NA_L2CODE, NA_L2NAME, NA_L1CODE, NA_L1NAME, NA_L2KEY, NA_L1KEY, Shape_Leng, Shape_Area
min values : 10.2, WARM DESERTS, 10, NORTH AMERICAN DESERTS, 10.2 WARM DESERTS, 10 NORTH AMERICAN DESERTS, 11613.69, 8382714
max values : 10.2, WARM DESERTS, 10, NORTH AMERICAN DESERTS, 10.2 WARM DESERTS, 10 NORTH AMERICAN DESERTS, 11456404.58, 510159399963
我需要循环执行此操作,因为我还包括其他分析。
Ecoregions.list <- c("ER_10.2", "ER_12.1", "ER_14.3","ER_13.2",
"ER_09.6", "ER_09.5", "ER_14.1", "ER_13.3", "ER_09.4", "ER_08.3", "ER_13.1", "ER_11.1")
Ecoregions<-unique(as.character(Ecoregions.list))
for(i in 1:length(Ecoregions))
{
Ecoregions<-unique(as.character(Ecoregions.list))
ER=as.name(Ecoregions[i])
plot (ER)
}
但是当我尝试在图中阅读以绘制它时,我总是会收到此错误:
Error in xy.coords(x, y, xlabel, ylabel, log) : invalid first argument
有人对如何解决此问题有任何建议吗?
提前致谢!