2

It takes lots of time when reading laz files when you iterate hundreds of laz file. But reading only the header can only takes less than 100 ms to read hundreds of las files.

The same problems arises when reading all attributes of laz files. The time it cost to decompress all the attributes is too much. Is there any method to read only attribute wanted? For example:only read the X can read faster?

class LASLIB_DLL LASreader
{
public:
  LASheader header;
  LASpoint point;

  I64 npoints;
  I64 p_count;

  //[...]

  BOOL read_point() { return (this->*read_simple)(); };

  //[...]
}
for (int i = 0 ; i < 1000 ; i++)
{ 
   lasReader->read_point();
   LASpoint& pointReader = lasReader->point;
   double x = pointReader.get_x();
}

If I want to read any attribute of laz file, I have to decompress whole things of class LASreader. That's just too slow and make no-sense.

1

To read only the header this is how I proceed. My code interfaces the result with the R language so don't be surprised by the List or CharacterVector. You can change it to fit your need. You can retrieve the entire source code here.

std::string filestd = as<std::string>(file);

LASreadOpener lasreadopener;
lasreadopener.set_file_name(filestd.c_str());

LASreader* lasreader = lasreadopener.open();
LASheader* lasheader = &lasreader->header;

if((0 == lasreader) || (NULL == lasreader))
  throw std::runtime_error("LASlib internal error. See message above.");

char cguid[38];
sprintf(cguid, "%08x-%04x-%04x-%04x-%04x%08x",
   lasheader->project_ID_GUID_data_1,
   lasheader->project_ID_GUID_data_2,
   lasheader->project_ID_GUID_data_3,
   *((U16*)(lasheader->project_ID_GUID_data_4)),
   *((U16*)(lasheader->project_ID_GUID_data_4+2)),
   *((U32*)(lasheader->project_ID_GUID_data_4+4)));

CharacterVector guid(cguid);

List head(0);
head.push_back(lasheader->file_signature);
head.push_back(lasheader->file_source_ID);
head.push_back(globalencodingreader(lasheader));
head.push_back(guid);
head.push_back((int)lasheader->version_major);
head.push_back((int)lasheader->version_minor);
head.push_back(lasheader->system_identifier);
head.push_back(lasheader->generating_software);
head.push_back(lasheader->file_creation_day);
head.push_back(lasheader->file_creation_year);
head.push_back(lasheader->header_size);
head.push_back(lasheader->offset_to_point_data);
head.push_back(lasheader->number_of_variable_length_records);
head.push_back((int)lasheader->point_data_format);
head.push_back(lasheader->point_data_record_length);
// [...]

To selectively decompress some attribute LASzip defines some stuff but I don't know where and how to use it. The source code is here. There is something in LASreadOpener called void set_decompress_selective(U32);. But it seems it applies only to LAS 1.4 according to the comment L326 // optional selective decompression (compressed new LAS 1.4 point types only)

#define LASZIP_DECOMPRESS_SELECTIVE_ALL                0xFFFFFFFF

#define LASZIP_DECOMPRESS_SELECTIVE_CHANNEL_RETURNS_XY 0x00000000
#define LASZIP_DECOMPRESS_SELECTIVE_Z                  0x00000001
#define LASZIP_DECOMPRESS_SELECTIVE_CLASSIFICATION     0x00000002
#define LASZIP_DECOMPRESS_SELECTIVE_FLAGS              0x00000004
#define LASZIP_DECOMPRESS_SELECTIVE_INTENSITY          0x00000008
#define LASZIP_DECOMPRESS_SELECTIVE_SCAN_ANGLE         0x00000010
#define LASZIP_DECOMPRESS_SELECTIVE_USER_DATA          0x00000020
#define LASZIP_DECOMPRESS_SELECTIVE_POINT_SOURCE       0x00000040
#define LASZIP_DECOMPRESS_SELECTIVE_GPS_TIME           0x00000080
#define LASZIP_DECOMPRESS_SELECTIVE_RGB                0x00000100
#define LASZIP_DECOMPRESS_SELECTIVE_NIR                0x00000200
#define LASZIP_DECOMPRESS_SELECTIVE_WAVEPACKET         0x00000400
#define LASZIP_DECOMPRESS_SELECTIVE_BYTE0              0x00010000
#define LASZIP_DECOMPRESS_SELECTIVE_BYTE1              0x00020000
#define LASZIP_DECOMPRESS_SELECTIVE_BYTE2              0x00040000
#define LASZIP_DECOMPRESS_SELECTIVE_BYTE3              0x00080000
#define LASZIP_DECOMPRESS_SELECTIVE_BYTE4              0x00100000
#define LASZIP_DECOMPRESS_SELECTIVE_BYTE5              0x00200000
#define LASZIP_DECOMPRESS_SELECTIVE_BYTE6              0x00400000
#define LASZIP_DECOMPRESS_SELECTIVE_BYTE7              0x00800000
#define LASZIP_DECOMPRESS_SELECTIVE_EXTRA_BYTES        0xFFFF0000
2
  • 1
    thanks a lot, I will strive to figure out the _DECOMPRESS_SELECTIVE. And post here if succeed.
    – Lachiven
    Aug 4 at 1:59
  • Recently, I have test the selective decompress fuc of lastools. And post it here! Thanks again! @JRR
    – Lachiven
    Aug 11 at 8:35
0

Recently, I have test the selective decompress fuc of lastools. And, there's some time can save. Here is the notice and test result. notice:

  1. lasitem_version>3。

  2. las_version = 1.4 use:

lasReaderOpener.set_decompress_selective(laszip_DECOMPRESS_SELECTIVE_CHANNEL_RETURNS_Z);//for more section to see laszip_decompress_selective_v3.hpp

test result:

compress all:

enter image description here

only 56% time takes!

compress selective:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.