R语言与GIS:[6]点要素的操作(2)
点要素的操作(2)
移动点
移动点的操作主要是让所有点在一定区间内随机运动,产生随机位移的方法如下:
> move<-as.integer(runif(1,1,10))
> move
[1] 7
整体移动
利用for循环进行整体移动,程序如下:
> for(i in 1:length(x)){
+ move_x=as.integer(runif(1,-10000,10000))*90
+ move_y=as.integer(runif(1,-10000,10000))*90
+ x[i]<-x[i]+move_x
+ y[i]<-y[i]+move_y
+ }
组成新的点要素类:
> points_new<-data.frame(x,y,z)
> coordinates(points_new)<-~x+y
> summary(points_new)
Object of class SpatialPointsDataFrame
Coordinates:
min max
x -87475.35 1774205
y 3162303.36 4896779
Is projected: NA
proj4string : [NA]
Number of points: 40
Data attributes:
Min. 1st Qu. Median Mean 3rd Qu. Max.
893 1222 1328 1332 1450 1640
绘制新点
> plot(points_new)
点要素类的前后对比:
![R语言与GIS:[6]点要素的操作(2)](https://exp-picture.cdn.bcebos.com/732a12e265e7340f23748d9735b9763e20c2b4a0.jpg)
移动前
![R语言与GIS:[6]点要素的操作(2)](https://exp-picture.cdn.bcebos.com/6ca98461862541939ce429b0df1bd10ff326aba0.jpg)
移动后
(共篇)上一篇:点要素的操作(1)声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:143
阅读量:176
阅读量:193
阅读量:144
阅读量:26