Re: [LAStools] Using LASlib to add VLR to LAS-header.

201 views
Skip to first unread message

Martin Isenburg

unread,
Jan 12, 2013, 2:34:42 AM1/12/13
to last...@googlegroups.com
Hello Andreas,

below I give the correct order of instructions. Also you should use 34737 and not 34735 for the user_id.

LASreader* lasreader = lasreadopener.open();

U8* data = new U8[32];
memset(data,0,32);
strncpy((char*)data, "EPSG::25832", 32);
lasreader->header.add_vlr("
LASF_Projection", 34737, 32, data);

LASwriter* laswriter = laswriteopener.open(&lasreader->header);

while (lasreader->read_point())
{
  laswriter->write_point(&lasreader->point);
  laswriter->update_inventory(&lasreader->point);
}
laswriter->update_header(&lasreader->header, TRUE);

Cheers,

Martin

PS: You cannot add a VLR after the fact. It need to be added before opening the new file and before writing the points.


On Thu, Jan 10, 2013 at 10:20 PM, Andreas Røstad <andreas...@statkart.no> wrote:

I try to use LASlib to insert crs-information in the header of a transformed LAS-file. To do this I need to insert some VLR in the header.

I use this code:

U8* data = new U8[32];

memset(data,0,32);

strncpy((char*)data, "EPSG::25832", 32);

lasreader->header.add_vlr("LASF_Projection", 34735, 32, data);

 

laswriter->update_header(&lasreader->header, TRUE, TRUE);

 

It compiles and runs without errors, but the resulting LAS-file does not have any VLR in the header.

I do not fully understand the sourcecode of LASlib, but I think there may be an error in LASwriterLAS::update_header:

  …

if (update_extra_bytes)

{

  if (header == 0)     

  {

    fprintf(stderr,"ERROR: header pointer is zero\n");

    return FALSE;

  }

  if (header->number_extra_attributes)

  {

    I64 start = header_start_position + header->header_size;

    for (i = 0; i < (I32)header->number_of_variable_length_records; i++)

    {

 

Perhaps the yellow number_extra_attributes should have been changed to number_of_variable_length_records?

 

Andreas 

--
Download LAStools at
http://lastools.org/
Visit the LAStools group at
http://groups.google.com/group/lastools/
Be social with LAStools at
http://www.facebook.com/LAStools
http://www.twitter.com/LAStools

Reply all
Reply to author
Forward
0 new messages