我有很多坐标:
> xh1
[1] 257283.7 258592.6 261811.6 262768.6 257283.7
> yh1
[1] 2639722 2640722 2640722 2639722 2639722
> xh2
[1] 257283.7 256523.3 263725.6 262768.6 257283.7
> yh2
[1] 2639722 2638722 2638722 2639722 2639722
... ...
使用“cbind”,我想准备要转换为多边形的坐标:
poly1<-cbind(xh1,yh1)
poly2<-cbind(xh2,yh2)
... ...
> poly1
xh1 yh1
[1,] 257283.7 2639722
[2,] 258592.6 2640722
[3,] 261811.6 2640722
[4,] 262768.6 2639722
[5,] 257283.7 2639722
... ...
poly<- Polygon(poly1)
... ...
是否可以使用循环在 R 中执行“cbind”任务?我知道像下面这样的东西是行不通的:
poly<-lapply(1:100, function(i) cbind(paste0("xh",i), paste0("yh",i)))