Binary_template + read_binary [message #53891] |
Wed, 09 May 2007 09:00  |
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 #53989 is a reply to message #53891] |
Wed, 09 May 2007 09:15  |
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
|
|
|