[pdal] How to get las header info?

Peder Axensten Peder.Axensten at slu.se
Tue Jul 5 10:06:43 PDT 2022


I tried that too. :-)
I tried the following, inspired by code on https://pdal.io/api/transition/index.html:

    pdal::LasHeader get_header( const std::filesystem::path & path_ ) {
        pdal::Option              las_opt( "filename", path_.native() );
        pdal::Options             las_opts;
        las_opts.add( las_opt );

        pdal::PointTable          table;
        pdal::LasReader           las_reader;
        las_reader.setOptions( las_opts );
        las_reader.prepare( table );

        pdal::PointViewSet        point_view_set = las_reader.execute( table );
        pdal::PointViewPtr        point_view = *point_view_set.begin();
        pdal::Dimension::IdList   dims = point_view->dims();
        return las_reader.header();
    }

However, no header info seems to actually be read – I get bogus information. No error or exception, just bogus info.
What am I missing?

Best regards,

Peder Axensten
Systems Developer

Remote Sensing
Department of Forest Resource Management
Swedish University of Agricultural Sciences
SE-901 83 Umeå
Visiting address: Skogsmarksgränd
Phone: +46 90 786 85 00
peder.axensten at slu.se, www.slu.se/srh

The Department of Forest Resource Management is environmentally certified in accordance with ISO 14001.

> On 5 Jul 2022, at 17:03, Andrew Bell <andrew.bell.ia at gmail.com> wrote:
>
>
> CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
>
>
> LasReader provides the header() function that returns a reference to the LasHeader.
>
> On Tue, Jul 5, 2022 at 10:50 AM Peder Axensten <Peder.Axensten at slu.se> wrote:
> Hello again,
>
> I tried the 2.4.2 version and I notice that the copy and move constructors (and operators) are now implemented.
> But pdal::LasHeader now lacks the default constructor, so this code still does not work:
>
>     pdal::LasHeader get_header( const std::filesystem::path & path_ ) {
>         pdal::LasHeader          header{};   // error: no matching constructor for initialization of 'pdal::LasHeader'
>         pdal::ILeStream          input{ path_.native() };
>         input >> header;
>         return header;
>     }
>
> What would be the correct way to read the header information from my code?
> It would be nice to do it for any point cloud file, but I’m happy to settle for las/laz files.
>
> Best regards,
>
> Peder Axensten
> Systems Developer
>
> Remote Sensing
> Department of Forest Resource Management
> Swedish University of Agricultural Sciences
> SE-901 83 Umeå
> Visiting address: Skogsmarksgränd
> Phone: +46 90 786 85 00
> peder.axensten at slu.se, www.slu.se/srh
>
> The Department of Forest Resource Management is environmentally certified in accordance with ISO 14001.
>
> > On 23 Mar 2022, at 12:34, Andrew Bell <andrew.bell.ia at gmail.com> wrote:
> >
> > On Wed, Mar 23, 2022 at 5:14 AM Peder Axensten <Peder.Axensten at slu.se> wrote:
> > Dear list,
> >
> > Previously, I could obtain a pdal::LasHeader through:
> >
> > inline pdal::LasHeader get_header( const std::filesystem::path & path_ ) {
> > pdal::LasHeader header;
> > pdal::ILeStream input{ path_.native() };
> > input >> header;
> > return header;
> > }
> >
> > But in the latest version of pdal the header copy constructor is implicitly deleted.
> >
> > This issue has already been reported and fixed and will be included in the final 2.4 release:
> >
> >  https://github.com/PDAL/PDAL/pull/3713
> >
> > The tool needs to process all las-files of a specified directory (and its sud-directories). If I need to read the contents of files that could actually be ignored, it would increase processing time probably tenfolds. Is there a way to avoid this?
> >     Maybe a previous stage in the pipeline to filter files based only on their header (bounding box) info?
> >     If I implement it as a streaming operation, could I get the bounding box from header info and possibly not stream anything?
> >
> > The bounding box of a LAS file is always stored at offsets 179-226, so you can read them directly if you like, but as I said above, I have re-enabled copying of LasHeader.
> >
> > --
> > Andrew Bell
> > andrew.bell.ia at gmail.com
>
> ---
> När du skickar e-post till SLU så innebär detta att SLU behandlar dina personuppgifter. För att läsa mer om hur detta går till, klicka här <https://www.slu.se/om-slu/kontakta-slu/personuppgifter/>
> E-mailing SLU will result in SLU processing your personal data. For more information on how this is done, click here <https://www.slu.se/en/about-slu/contact-slu/personal-data/>
>
>
> --
> Andrew Bell
> andrew.bell.ia at gmail.com

---
När du skickar e-post till SLU så innebär detta att SLU behandlar dina personuppgifter. För att läsa mer om hur detta går till, klicka här <https://www.slu.se/om-slu/kontakta-slu/personuppgifter/>
E-mailing SLU will result in SLU processing your personal data. For more information on how this is done, click here <https://www.slu.se/en/about-slu/contact-slu/personal-data/>


More information about the pdal mailing list