[pdal] Accessing point data directly

Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[pdal] Accessing point data directly

Stephen Pidgeon

Hi all,

 

I am writing a C++ program that makes use of PDAL. I would like to be able to read in a file (for example a .las file) and then access the data for the points directly. For example I’d like to know the X, Y, and Z values for the first point. How would be the best way of doing this? I’ve been looking through the API but I’m not entirely sure what I’m looking for. I’ve managed to use the readers, writers, and filters, but I’m struggling to work out how to access the data. If someone could give me a point in the right direction that would be great!

 

Thanks,

Stephen

 

Sent from Mail for Windows 10

 


_______________________________________________
pdal mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/pdal
Reply | Threaded
Open this post in threaded view
|

Re: [pdal] Accessing point data directly

Andrew Bell-2
1) If you're doing processing as in a PDAL pipeline, you can just write a stage that does the processing you wish.  Take a look at:


If all you want to do is read the data, you can just implement run() or filter().


2) If you want to read all the points into memory and then access the data you can do something like:

main()
{
  PointTable t;

  LasReader r;
  Options o;
  o.add("filename", "somefile.las");
  r.setOptions(o);

  r.prepare(t);
  PointViewSet s = r.execute(t);
  PointViewPtr v = *s.begin();  // Assumes one PointView

  for (PointId id = 0; i < v.size(); ++i)
  {
    double x = v->getFieldAs<double>(Dimension::Id::X, i);
    double y = v->getFieldAs<double>(Dimension::Id::Y, i);
    double z = v->getFieldAs<double>(Dimension::Id::Z, i);
}

If you have the source or are looking at it on Github, there are lots of examples of how you might access data in the test/unit directory.

Hope that helps,


On Mon, Dec 4, 2017 at 9:00 AM, <[hidden email]> wrote:

Hi all,

 

I am writing a C++ program that makes use of PDAL. I would like to be able to read in a file (for example a .las file) and then access the data for the points directly. For example I’d like to know the X, Y, and Z values for the first point. How would be the best way of doing this? I’ve been looking through the API but I’m not entirely sure what I’m looking for. I’ve managed to use the readers, writers, and filters, but I’m struggling to work out how to access the data. If someone could give me a point in the right direction that would be great!

 

Thanks,

Stephen

 

Sent from Mail for Windows 10

 


_______________________________________________
pdal mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/pdal



--
Andrew Bell
[hidden email]

_______________________________________________
pdal mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/pdal