[Liblas-devel] Written file can't be read by other .las viewers
Howard Butler
hobu.inc at gmail.com
Fri Aug 26 09:11:07 EDT 2011
On Aug 25, 2011, at 6:16 PM, James Hargrave wrote:
> Hello,
>
> When I use laslib to create a file I am able to then read the file back in
> and everything seems fine. However, I am unable to view the file in other
> applications such as the lasview.exe utility found here:
>
> http://www.cs.unc.edu/~isenburg/lastools/
>
> The steps I use mirror the C++ tutorial from the laslib.org site:
>
> ofs.open((char*)filename, ios::out | ios::binary);
> liblas::Header header;
>
> writer = new liblas::Writer(ofs, header);
>
> Then in a loop:
>
> liblas::Point point;
> point.SetCoordinates(pt.X(), pt.Y(), pt.Z());
>
> // fill other properties of point record
> if ( rgb )
> point.SetColor( liblas::Color( rgb[0], rgb[1], rgb[2] ) );
>
> writer->WritePoint(point);
>
>
> If anyone has any ideas I'd appreciate any suggestions. If it would help I
> can also provide a sample output file which I am able to read back in using
> liblas but does not appear when loaded into lasview.exe .
>
> Thanks,
> - James
James,
Which version of libLAS are you using? The following just worked for me this morning with the latest git HEAD on https://github.com/libLAS/libLAS
~/liblas$ las2las TO_core_last_zoom.las lastools-test-from-liblas.las
~/lastools/bin/lasinfo lastools-test-from-liblas.las
> reporting all LAS header entries:
> file signature: 'LASF'
> file source ID: 0
> reserved (global_encoding):0
> project ID GUID data 1-4: 0 0 0 ''
> version major.minor: 1.0
> system identifier: ''
> generating software: 'TerraScan'
> file creation day/year: 0/0
> header size 227
> offset to point data 229
> number var. length records 0
> point data format 1
> point data record length 28
> number of point records 213093
> number of points by return 128621 84472 0 0 0
> scale factor x y z 0.01 0.01 0.01
> offset x y z -0 -0 -0
> min x y z 630250.00 4834500.00 46.83
> max x y z 630500.00 4834750.00 170.65
> the header is followed by 2 user-defined bytes
> reporting minimum and maximum for all LAS point record entries ...
> x 63025000 63050000
> y 483450000 483475000
> z 4683 17065
> intensity 10 50200
> edge_of_flight_line 0 0
> scan_direction_flag 0 0
> number_of_returns_of_given_pulse 1 2
> return_number 1 2
> classification 1 1
> scan_angle_rank 0 0
> user_data 2 4
> point_source_ID 0 0
> gps_time 413162.560400 414095.322000
> overview over number of returns of given pulse: 128621 84472 0 0 0 0 0
> histogram of classification of points:
> 213093 Unclassified (1)
Are you making sure to delete the writer in your code? You must delete the writer because it will be writing header details at the end of writing. Also, make sure to do ofs.close() to force the flush of any data left in the ostream buffer.
Howard
More information about the Liblas-devel
mailing list