【问题标题】:Creating 2D grid or mesh inside a cross section profile在横截面轮廓内创建二维网格或网格
【发布时间】:2019-03-25 20:08:41
【问题描述】:

R 中的二维网格? 我有一个河流横截面,其剖面是 Y 与 Z。 并且想在通道床和水深之间创建一个网格。三角形和矩形网格都可以。网格可以相距 0.01 x 0.01 m 或任何其他。我的目标是获取每个网格的 Y 和 Z 坐标。 提前感谢您的友好合作

个人资料数据

Y=c(-30,-2,0,8,20,31) 
Z=c(30,10,2,9,30,39)

【问题讨论】:

  • 欢迎您!你的问题非常广泛。请edit您的问题并尝试添加您已经尝试过的一些细节和相关代码。
  • 嗨,我可以自己做。也许你可以检查一下,请@ventiseis

标签: r intersection mesh profile


【解决方案1】:
  • 自从我发布这个以来,我一直在努力,终于可以开发代码了
  • 任何人都可以使用它。 -这是横截面轮廓

Y=c(-30,-2,0,8,20,31)

Z=c(30,10,2,9,30,39)

-在横截面内创建点网格 - 选择 y 和 z 网格间距

ygrid= 50 #cm zgrid= 20 #cm

Ym = seq(min(Y),max(Y),ygrid/100#y 沿截面的网格坐标

创建插值函数

f_z=approxfun(Y,Z) 
Zm = f_z(Ym)             #interpolated z coordinates of the section perimeter

plot(Ym, Zm,type="b")

我们观察到的海浪的深度。速度或Q放电

Depth_study = 6.05

创建从剖面床到研究深度的不同深度

Depthm = seq(Z_bed,Depth_study,zgrid/100) # different water depths w/r to 0,0 point

现在对于不同的深度,取出 Zm 的索引

list_points_mesh<-vector(("list"),length =length(Depthm))

Y_mesh<-vector(("list"),length =length(Depthm))

Z_mesh<-vector(("list"),length =length(Depthm))

for (j in 1:length(Depthm)) {
  list_points_mesh[[j]] = which(Zm<=Depthm[j])  #gives indice of all the points which are below Depthm elevation
  Y_mesh[[j]] = Ym[list_points_mesh[[j]]]  #now we create pair of points using the indices
  Z_mesh[[j]]= rep(Depthm[j],length(list_points_mesh[[j]]))
}

由于答案以列表的形式出现,我们通过 unlist func 将它们取出。

ym=unlist(Y_mesh)   #y coord of the grid points
zm=unlist(Z_mesh)  #z // //    //   //
mesh_coord <- data.frame(ym,zm)  #list of points inside the section
points(ym,zm,pch=".")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-09-19
    • 2012-11-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多