資源簡介
matlab打開las點云文件的程序,也就是m文件,能夠打開激光點云的las文件
代碼片段和文件信息
function?A?=?LASreadAll(infilename)
%?LASREADALL?reads?in?all?variables?from?a?LAS?1.x?data?file?(used?with?lidar?data)?
%
%?INPUT
%?infilename:?input?file?name??(for?example?‘myinfile.las‘)?
%???????????
%?OUTPUT
%?A:????This?is?a?structure?containing?all?the?data?in?the?file.
%?????????See?the?file?documentation?for?more?information:
%?http://www.asprs.org/Committee-General/LASer-LAS-File-Format-Exchange-Activities.html
%?
%?EXAMPLE
%?A?=?LASreadAll(‘infile.las‘)
%
%?Cici?Alexander
%?????September?2008?(updated?26.09.2008)
%?Amy?Farris?(afarris@usgs.gov)?
%??????November?2013?Substatially?altered?to?read?in?all?variables?from?the?file
%?This?file?has?the?capability?to?load?data?files?using?any?1?of?5?formats.
%?However?I?was?only?able?to?test?it?with?one?of?the?formats.?
%?I?included?support?for?the?rest?of?the?file?formats?b/c?I
%?thought?someone?might?find?it?useful.??I?sure?hope?they?work!!!
%?If?the?code?crashes?it?may?be?because?either?the?pointDataFormatID?
%?value?was?not?what?I?expected?or?the?value?for?pointDataRecordLength?
%?is?not?what?I?think?it?should?be?based?on?the?format?ID.??
%?If?pointDataRecordLength?is?different?than?I?expected?then?you?may?need?
%?to?change?the?values?in?fseek?eg:?(c+????)
%?The?number?added?to?c?should?be?the?sum?of?bytes?of?all?the?variables?
%?that?occur?before?the?variable?currently?being?read?in.
%
%?Also?the?file?I?tested?this?code?with?was?LAS?format?1.2?I?
%?think?this?code?will?run?on?later?versions?of?LAS.
%
%?A?brief?explanation?of?the?LAS?file?format:
%?LAS?files?are?binary?they?begin?with?header?information.??Included?in
%?the?header?is?the?size?of?the?header?(in?bytes);?this?is?called
%?‘OffsetToPointData‘?refered?to?a?‘c‘?in?this?code.??After?c?bytes?the
%?data?begins?with?the?first?x?value?then?the?first?y?value?and?so?on...
%?(exactly?what?data?is?included?depends?on?the?file?format).??Then?the
%?file?continues?with?the?second?x?value?the?second?y?value?and?so?on...??
%?The?header?tells?you?how?many?bytes?of?data?there?are?for?each?data?point
%?(‘pointDataRecordLength‘?also?refered?to?as?‘p‘?in?this?code).
%?So?to?read?in?all?the?x?values?you?start?at?the?beginig?of?the?file?and
%?skip?c?bytes:??“(fseek(fid?c?‘bof‘);“??
%?Then?you?read?in?one?value?and?skip?p-4?bytes?
%?(each?x?value?consists?of?4?bytes)?and?then?read?the?next?x?and?so?on:
%?“X1?=?fread(fidinf‘int32‘p-4);“
%
%?This?is?my?(Amy?Farris‘)?first?attempt?at?reading?in?a?binary?file.??
%?I?depended?strongly?on?Cici‘s?orignal?file?(LASRead.m)?at?first.??Most?
%?of?the?code?after?about?line?#?134?was?written?by?me?as?are?these
%?garrolous?beginning?comments.??I?hope?they?help.
%%?Open?the?file
fid?=fopen(infilename);
%?Check?whether?the?file?is?valid
if?fid?==?-1
????error(‘Error?opening?file‘)
end
%%?Read?in?important?information?from?the?header
%?Check?whether?the?LAS?format?is?1.1
fseek(fid?24?‘bof‘);
VersionMajor?=?fread(fid1‘uchar‘);
- 上一篇:圖像加密的源代碼
- 下一篇:E5 信號導航電文階梯碼構造
評論
共有 條評論