IDL读取并三维显示Lidar数据

来源:互联网 发布:程序员创业 方向选择 编辑:程序博客网 时间:2024/05/29 10:52

  首先感谢penpaopen(http://hi.baidu.com/penpaopen/blog/item/8ab09c1784370d4020a4e909.html)关于激光雷达数据LAS文件结构介绍,以及IDL读取Lidar数据的启示,结合坛子里C++读取LAS文件的实现方法和实验数据,实现了利用IDL三维显示Lidar数据。具体代码如下:

IDL读Lidar数据

pro ReadLAS,sFile


header = { $
    signature       : byte('LASF'), $               ; File signature
    fileSource      : 0US, $                       ; File source ID
    reserved        : 0US, $                       ; Reserved
    guid1           : 0UL, $                        ; Project ID - GUID data 1
    guid2           : 0US, $                       ; Project ID - GUID data 2
    guid3           : 0US, $                       ; Project ID - GUID data 3
    guid4           : bytarr(8), $                  ; Project ID - GUID data 4
    versionMajor    : 1B, $                         ; Version major
    versionMinor    : 1B, $                         ; Version minor
    systemID        : bytarr(32), $                 ; System identifier
    softwareID      : bytarr(32), $                 ; Generating software
    day             : 0US,    $                     ; File creation day of year
    year            : 0US,    $                     ; File creation year
    headerSize      : 227US, $                     ; Header size
    dataOffset      : 227UL, $                      ; Offset to point data
    nRecords        : 0UL,   $                      ; Number of variable length records
    pointFormat     : 0B,    $                      ; Point data format ID
    pointLength     : 20US,   $                     ; Point data record length
    nPoints         : 0UL,   $                      ; Number of point records
    nReturns        : ulonarr(5), $                 ; Number of points by return
    xScale          : 0D, $                         ; X scale factor
    yScale          : 0D, $                         ; Y scale factor
    zScale          : 0D, $                         ; Z scale factor
    xOffset         : 0D, $                         ; X offset
    yOffset         : 0D, $                         ; Y offset
    zOffset         : 0D, $                         ; Z offset
    xMax            : 0D, $                         ; Max X
    xMin            : 0D, $                         ; Min X
    yMax            : 0D, $                         ; Max Y
    yMin            : 0D, $                         ; Min Y
    zMax            : 0D, $                         ; Max Z
    zMin            : 0D $                         ; Min Z
}

data = {formatD0, $
            east    : 0L, $     ; X data
            north   : 0L, $     ; Y data
            elev    : 0L, $     ; Z data
            inten   : 0US, $     ; Intensity            
            nReturn : 0B, $     ; Return number, number of returns, scan direction, edge
            class   : 0B, $     ; Classification
            angle   : 0B, $     ; Scan angle
            user    : 0B, $     ; User data
            source : 0US $     ; Point source ID
}


openr, inputLun, sFile, /get_lun;, /swap_if_big_endian
readu, inputLun, header

c=bytarr(1)
ReadU, inputLun, c
ReadU, inputLun, c

 gps_time=DOUBLE(0.0)

datax=DBLARR(3,header.nPoints)
n=0
for i=0,header.nPoints-1  do begin
  ReadU, inputLun, data
  datax[0,i]=data.east*header.xScale+header.xOffset;
  datax[1,i]=data.north*header.yScale+header.yOffset;
  datax[2,i]=data.elev*header.zScale+header.zOffset;
  ReadU, inputLun, gps_time
endfor

free_lun, inputLun

end

test1.las和test2.las三维显示