[Liblas-devel] Written file can't be read by other .las viewers
Martin Isenburg
martin.isenburg at gmail.com
Fri Aug 26 15:53:06 EDT 2011
hi,
to have a "proper" LAS file you should set the
number_of_returns_of_given_pulse and the return_number of each point (see
the reamining warnings of lasinfo).
if you have one return per pulse ... set them both to 1.
and i guess i should put something into lasview that automatically detects
it when the bounding box is set to 0 0 0 / 0 0 0 and then computes it on the
fly ...
cheers,
martin
On Fri, Aug 26, 2011 at 12:39 PM, James Hargrave <jhargrave at photomodeler.com
> wrote:
> Hey guys,
>
> Thanks for the suggestions and help. Running the repair gave me the clue I
> needed. I wasn't setting the min/max values to the header.
>
> Here's the output from the repair:
> 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.2
> system identifier: 'libLAS'
> generating software: 'libLAS 1.7.0b2'
> file creation day/year: 237/2011
> header size 227
> offset to point data 227
> number var. length records 0
> point data format 3
> point data record length 34
> number of point records 5857
> number of points by return 0 0 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 0.00 0.00 0.00
> max x y z 0.00 0.00 0.00
> reporting minimum and maximum for all LAS point record entries ...
> x -1323 1581
> y -831 983
> z -3855 -1905
> intensity 0 0
> edge_of_flight_line 0 0
> scan_direction_flag 0 0
> number_of_returns_of_given_pulse 0 0
> return_number 0 0
> classification 0 0
> scan_angle_rank 0 0
> user_data 0 0
> point_source_ID 0 0
> gps_time 0.000000 0.000000
> Color R 0 220
> G 1 243
> B 0 255
> WARNING: there are 5857 points with return number 0
> WARNING: there are 5857 points with a number of returns of given pulse of 0
> histogram of classification of points:
> 5857 Created, never classified (0)
> real max x larger than header max x by 15.810000 (repaired)
> real min x smaller than header min x by 13.230000 (repaired)
> real max y larger than header max y by 9.830000 (repaired)
> real min y smaller than header min y by 8.310000 (repaired)
> real min z smaller than header min z by 38.550000 (repaired)
>
>
>
> I added these lines after writing all the points (and computing the min/max
> during the write):
>
> header.SetMin( min.X(), min.Y(), min.Z() );
> header.SetMax( max.X(), max.Y(), max.Z() );
>
> writer->SetHeader(header);
> writer->WriteHeader();
>
>
> This fixed the problem.
>
> Are there any other fields I should be specifically setting?
>
>
> Heaps of thanks,
> - James
>
>
>
> > -----Original Message-----
> > From: Howard Butler [mailto:hobu.inc at gmail.com]
> > Sent: August-26-11 6:33 AM
> > To: James Hargrave
> > Cc: liblas-devel
> > Subject: Re: [Liblas-devel] Written file can't be read by other .las
> > viewers
> >
> >
> > On Aug 26, 2011, at 8:11 AM, Howard Butler wrote:
> >
> > >
> > > 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.
> >
> > After some discussion on IRC with Martin, he suggested you run the
> > following:
> >
> > ~/lastools $ lasinfo -repair file-written-by-liblas.las
> >
> > I don't think your code is updating the header's bounds and return count
> > information, and this might be required for lasview.exe to run.
> >
> > Howard
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/liblas-devel/attachments/20110826/da699308/attachment-0001.html
More information about the Liblas-devel
mailing list