This question already has an answer here:
I am just starting to use libLAS and I had a small issue.
I have next code to generate a las file with georeferenced points:
std::ofstream ofs; liblas::Header header; liblas::SpatialReference srs; srs.SetFromUserInput("EPSG:4326"); header.SetSRS(srs); header.SetPointRecordsCount(1); ofs.open("H:\\temp\\test2.las", std::ios::out | std::ios::binary); liblas::Writer writer(ofs, header); liblas::Point point(&header); point.SetCoordinates(1.0, 2.0, 3.0); writer.WritePoint(point); point.SetCoordinates(5, 5, 5); writer.WritePoint(point); point.SetCoordinates(-1, -1, -1); writer.WritePoint(point); header.SetPointRecordsCount(3); writer.SetHeader(header); writer.WriteHeader(); ofs.Close();
When I run lasinfo over this file I get: It says that I have 3 points, but my spatial reference is none.
Same code above, but if I comment this line:
I can see the spatial reference, but the number of points is 1.
Am I doing something wrong?