【问题标题】:Plot georeferenced raster images in Plotly (R API)在 Plotly (R API) 中绘制地理参考光栅图像
【发布时间】:2016-08-25 09:53:50
【问题描述】:

我想在 R 中使用Plotly 来创建考古发掘战壕的 3D 模型。我在绘制点和表面数据方面非常成功(例如:Vignette 我正在处理的R package),但我还想添加沟槽的地理参考轮廓图片的栅格信息。

我没有找到在 Plotlys 3D 环境中绘制栅格数据的任何方法。到目前为止我想出的唯一解决方案(感谢this 帖子)是使用SFM 使用Photoscan 创建配置文件的3D 模型,将彩色网格导出为.ply 文件,修复此文件的标题并将其导入 R 以使用以下示例代码进行绘图:

library(geomorph)
library(plotly)

#load data
mesh <- read.ply("plotly/expply8_corr.ply", ShowSpecimen = FALSE)

# extract vertex coordinates
x <- mesh$vb["xpts",]
y <- mesh$vb["ypts",]
z <- mesh$vb["zpts",]

# plot
plot_ly(
  x = x, y = y, z = z,
  i = mesh$it[1,]-1, j = mesh$it[2,]-1, k = mesh$it[3,]-1,
  facecolor = c(mesh$material$color[1, ]),
  type = "mesh3d"
)

您将找到示例数据here。

不幸的是,这真的很糟糕。如果你增加网格分辨率,一切都会变慢。我真的很想添加一个简单的地理参考栅格以保持高性能并避免创建配置文件的 3D 模型的必要性。是否有使用 Plotly 或其他绘图库实现此目的的工作流程?

【问题讨论】:

    标签: r geolocation raster plotly


    【解决方案1】:

    我通过包rgl 找到了一个不错的解决方案。示例:

    library(rgl)
    library(jpeg)
    
    # download and load picture
    download.file(
      url = 'https://upload.wikimedia.org/wikipedia/en/6/6d/Chewbacca-2-.jpg',
      destfile = "chewbacca.jpg",
      mode = 'wb'
    )
    
    chewie <- readJPEG("chewbacca.jpg", native = TRUE)
    
    # create some sample data
    x <- sort(rnorm(1000))
    y <- rnorm(1000)
    z <- rnorm(1000) + atan2(x, y)
    
    # plot sample data
    plot3d(x, y, z, col = rainbow(1000), size = 5)
    
    # add picture
    show2d(
      # plot raster
      {
        par(mar = rep(0, 4))
        plot(
          0:1, 0:1, type="n",
          ann = FALSE, axes = FALSE,
          xaxs = "i", yaxs = "i"
        )
        rasterImage(chewie, 0, 0, 1, 1)
      },
      # image position and extent
      # coordinate order: lower left, lower right, upper right and upper left
      x = c(-2,  1,  1, -2),
      y = c(-1, -1,  1,  1),
      z = c(-3, -3,  2,  2)
    )
    

    必须使用其他软件(GIS/CAD 中的摄影测量)对图片进行地理配准。如果您有地理参考栅格,您只需要其角点的坐标来绘制它。

    【讨论】:

      猜你喜欢
      • 2013-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-08
      • 2015-10-20
      • 2020-05-07
      • 1970-01-01
      • 2015-07-01
      相关资源
      最近更新 更多