comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Binary_template + read_binary
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Binary_template + read_binary [message #53891] Wed, 09 May 2007 09:00 Go to next message
rats06 is currently offline  rats06
Messages: 3
Registered: May 2007
Junior Member
Hi,

I have a LiDAR file in LAS FORMAT. I am trying to read this file using
BINARY_TEMPLATE and READ_BINARY but I am having some problems.
The only way I am being able to extract correctly all the information
is if I loop many times as the number of points I have in the dataset
and every time incrementing the TEMPLATE.OFFSET by 28 bytes.

What I mean is:

The format of the binary file should be:
Field1 = 4 bytes
Field2 = 4 bytes
Field3 = 4 bytes
Field4 = 2 bytes
Field5 = 1 byte
Field6 = 1 byte
Field7 = 1 byte
Field8 = 1 byte
Field9 = 2 bytes
Field10 = 8 bytes
Total number of bytes = 28

NUM_POINT_RECORDS = 276848 points

So, I create a TEMPLATE with BINARY_TEMPLATE with 10 fields using the
format above but using the NUMBER OF DIMENSIONS as a SCALAR.
Doing that and using the code:

for i = 0, NUM_POINT_RECORDS -1 do begin
data = read_binary(FILENAME, template=template)
template.offset[0] = template.offset[0] + 28
printf, ...
endfor

It works like that ... but of course too slow ... I tried putting the
NUMBER OF DIMENSIONS to 1 and using the NUM_POINT_RECORDS (276848
points) as the value ... but it doesn't work ... the result is not
the same as when I loop ...

How can I do that without looping ?

Thank you
Re: Binary_template + read_binary [message #53982 is a reply to message #53891] Wed, 09 May 2007 11:13 Go to previous message
rats06 is currently offline  rats06
Messages: 3
Registered: May 2007
Junior Member
That is way faster ... :)

Thank you for your help,

Rafael
Re: Binary_template + read_binary [message #53983 is a reply to message #53891] Wed, 09 May 2007 11:12 Go to previous message
rats06 is currently offline  rats06
Messages: 3
Registered: May 2007
Junior Member
That is way faster ... :)

Thank you for your help,

Rafael
Re: Binary_template + read_binary [message #53989 is a reply to message #53891] Wed, 09 May 2007 09:15 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
rats06@gmail.com wrote:
> Hi,
>
> I have a LiDAR file in LAS FORMAT. I am trying to read this file using
> BINARY_TEMPLATE and READ_BINARY but I am having some problems.
> The only way I am being able to extract correctly all the information
> is if I loop many times as the number of points I have in the dataset
> and every time incrementing the TEMPLATE.OFFSET by 28 bytes.
>
> What I mean is:
>
> The format of the binary file should be:
> Field1 = 4 bytes
> Field2 = 4 bytes
> Field3 = 4 bytes
> Field4 = 2 bytes
> Field5 = 1 byte
> Field6 = 1 byte
> Field7 = 1 byte
> Field8 = 1 byte
> Field9 = 2 bytes
> Field10 = 8 bytes
> Total number of bytes = 28
>
> NUM_POINT_RECORDS = 276848 points
>
> So, I create a TEMPLATE with BINARY_TEMPLATE with 10 fields using the
> format above but using the NUMBER OF DIMENSIONS as a SCALAR.
> Doing that and using the code:
>
> for i = 0, NUM_POINT_RECORDS -1 do begin
> data = read_binary(FILENAME, template=template)
> template.offset[0] = template.offset[0] + 28
> printf, ...
> endfor
>
> It works like that ... but of course too slow ... I tried putting the
> NUMBER OF DIMENSIONS to 1 and using the NUM_POINT_RECORDS (276848
> points) as the value ... but it doesn't work ... the result is not
> the same as when I loop ...
>
> How can I do that without looping ?

Define a structure for your fields and use ASSOC.

cheers,

paulv

--
Paul van Delst Ride lots.
CIMSS @ NOAA/NCEP/EMC Eddy Merckx
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: How to write IDL log output to a file?
Next Topic: Re: math in graph title

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:26:50 PDT 2025

Total time taken to generate the page: 0.00541 seconds