C#调用LibLAS的方法(二)

/ 0评 / 4

上节说到生成了C#的API函数进行调用,那么下面我们就来调用试试吧~哈

 LASReader lasreader = new LASReader(fname);
                    LASPoint laspoint;

                    LASHeader lasheader = lasreader.GetHeader();
                     int point_no = 0;
                    StreamWriter sw = new StreamWriter(savefname);
                    sw.WriteLine("File Name: " + fname);
                     while (lasreader.GetNextPoint())
                      {
                            point_no += 1;
                            laspoint = lasreader.GetPoint();
                            sw.WriteLine("Point NO." + point_no + " X=" + laspoint.X + ", Y=" + laspoint.Y + ", Z=" + laspoint.Z + " Intensity=" + laspoint.Intensity.ToString()
                                + " ReturnNumber=" + laspoint.ReturnNumber + " NumberofReturns=" + laspoint.NumberOfReturns + " ScanDirectionFlag=" + laspoint.ScanDirection
                                + " EdgeofFlightLine=" + laspoint.FlightLineEdge + " Classification=" + laspoint.Classification + " ScanAngleRank=" + laspoint.ScanAngleRank
                                + " UserData=" + laspoint.UserData);
                       }

 

通过这段代码,就能将所有点的信息导出成txt的文件了,用UltraEdit查看的结果:

 847ca3f54e8831dd7709d75c

哈,后面的classification和userdata就省了~下次将头文件的信息获取出来!~

发表评论

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