C#调用LibLAS的方法(三)

/ 0评 / 0

上节说到读取点的全部信息,那么头文件的信息呢?

LASReader lasreader = new LASReader(fname);
LASPoint laspoint;
LASHeader lasheader = lasreader.GetHeader();

double x_max = lasheader.GetMaxX();
double x_min = lasheader.GetMinX();
double y_max = lasheader.GetMaxY();
double y_min = lasheader.GetMinY();
double z_max = lasheader.GetMaxZ();
double z_min = lasheader.GetMinZ();
string filesignature = lasheader.FileSignature;
string softwareid = lasheader.SoftwareId;
string version = lasheader.VersionMajor.ToString() + "." + lasheader.VersionMinor.ToString();
int headersize = lasheader.HeaderSize;
string createyear = lasheader.CreationYear.ToString();
double x_offset = lasheader.GetOffsetX();
double y_offset = lasheader.GetOffsetY();
double z_offset = lasheader.GetOffsetZ();

txt_info.AppendText("LAS Info");
txt_info.AppendText("\r\n");
txt_info.AppendText("File name:" + fname);
txt_info.AppendText("\r\n");
txt_info.AppendText("Version: " + version);
txt_info.AppendText("\r\n");
txt_info.AppendText("Create Year: " + createyear);
txt_info.AppendText("\r\n");
txt_info.AppendText("Header Size: " + headersize);
txt_info.AppendText("\r\n");
txt_info.AppendText("ProjectId: " + lasheader.ProjectId);
txt_info.AppendText("\r\n");
txt_info.AppendText("Number of Points: " + lasheader.PointRecordsCount.ToString());          txt_info.AppendText("\r\n");
txt_info.AppendText("Number of Points by Return1: " + lasheader.GetPointRecordsByReturnCount(0));
txt_info.AppendText("\r\n");
txt_info.AppendText("Number of Points by Return2: " + lasheader.GetPointRecordsByReturnCount(1));
txt_info.AppendText("\r\n");
txt_info.AppendText("Number of Points by Return3: " + lasheader.GetPointRecordsByReturnCount(2));
txt_info.AppendText("\r\n");
txt_info.AppendText("Number of Points by Return4: " + lasheader.GetPointRecordsByReturnCount(3));
txt_info.AppendText("\r\n");
txt_info.AppendText("Number of Points by Return5: " + lasheader.GetPointRecordsByReturnCount(4));
txt_info.AppendText("\r\n");
txt_info.AppendText("X Min: " + x_min);
txt_info.AppendText("\r\n");
txt_info.AppendText("X Max: " + x_max);
txt_info.AppendText("\r\n");
txt_info.AppendText("Y Min: " + y_min);
txt_info.AppendText("\r\n");
txt_info.AppendText("Y Max: " + y_max);
txt_info.AppendText("\r\n");
txt_info.AppendText("Z Min: " + z_min);
txt_info.AppendText("\r\n");              
txt_info.AppendText("Z Max: " + z_max);
txt_info.AppendText("\r\n");
txt_info.AppendText("X Offset: " + x_offset);
txt_info.AppendText("\r\n");
txt_info.AppendText("Y Offset: " + y_offset);
txt_info.AppendText("\r\n");
txt_info.AppendText("Z Offset: " + z_offset);
txt_info.AppendText("\r\n");
txt_info.AppendText("X Scale Factor: " + lasheader.GetScaleX().ToString());
txt_info.AppendText("\r\n");
txt_info.AppendText("Y Scale Factor: " + lasheader.GetScaleY().ToString());
txt_info.AppendText("\r\n");
txt_info.AppendText("Z Scale Factor: " + lasheader.GetScaleZ().ToString());
txt_info.AppendText("\r\n");

通过上述代码,基本能将所有的头文件信息包含了~截图如下:

a60df82d24e453de8b13992a

下回就该绘制出来这些点了!~哈,敬请期待啦~

发表评论

电子邮件地址不会被公开。 必填项已用*标注