LASLib不能利用LASreader对源文件进行修改

       尝试对原始las文件的点进行修改的需求包括点云着色、点云分类等,参考官网的例程发现,点云着色和点云简单分类都是需要新建一个las文件,对原始文件的点进行修改后写入到新文件中:

例如,官网中点云简单分类示例代码中的点云遍历部分:(lasexample_simple_classification.cpp

// loop over the points

    while (lasreader->read_point())
    {
      xpos = I32_FLOOR((lasreader->point.get_x() - lasreader->header.min_x)/step);
      ypos = I32_FLOOR((lasreader->point.get_y() - lasreader->header.min_y)/step);

      pos = ypos*xdim + xpos;

      if (grid_minz[pos] < R)
      {
        lasreader->point.set_classification(8);
        count++;
      }

      laswriter->write_point(&lasreader->point);
      laswriter->update_inventory(&lasreader->point);
    }

例如,官网中点云着色示例代码中的点云遍历部分:(lasexample_add_rgb.cpp

// loop over points and modify them

  // where there is a point to read
  while (lasreader->read_point())
  {
    // copy the point
    point = lasreader->point;
    // change RGB
    point.rgb[0] = point.rgb[1] = point.rgb[2] = U16_QUANTIZE(((point.get_z() - header.min_z)*65535.0)/(header.max_z - header.min_z));
    if (lasreader->point.get_classification() == 12) lasreader->point.set_classification(1);
    // write the modified point
    laswriter->write_point(&point);
  } 

感觉LASLib用不够爽快,不是全部开源,PDAL貌似一直在更新,下一步尝试一下PDAL,希望能像GDAL一样开源。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值