introduction to lidar - gis courses · introduction to lidar ... you will need to transform them to...

11
ESPM5295 16-Oct-17 1 Introduction to LiDAR Our goals here are to introduce you to LiDAR data, to show you how to download it for an area of interest, and to better understand the data and uses through some simple manipulations. In our project we’ll be calculating building and tree heights for your project area. The state on Minnesota has flown LiDAR for the entire state. Data may be interactively downloaded via the MN DNR MNTopo viewer (http://dnr.state.mn.us/maps/mntopo/index.html), or for larger areas via the MNGEO ftp site (ftp://ftp.lmic.state.mn.us/pub/data/elevation/lidar/). Raster DEMs, hillshades, contours, and the “raw” data or “point cloud” data may be downloaded, in ESRI geodatabases or in commonly supported formats. We will download LiDAR data and derived layers and prepare them for inclusion in our Campus GIS. We will first work with the processed layers, and later the raw data, primarily for building heights. We need to merge together several tiles for the complete St. Paul Campus. This is common when working with LiDAR. Our individual study areas are small, so we’ve only a few tiles. Open the MnTOPO website, and familiarize yourself with the tools near the upper right. Use the default display and the zoom button in the upper left, and click-hold-drag to pan, to get the approximate Campus area displayed. First, to use the download data tool (disk drive with arrow icon, in the toolbar row, upper/left), specify a small polygon that is centered on your individual project area. Download only one tile for each of the following: 1 m dem, 1m hillshade the raw lidar point cloud data (these will be .las or .laz (a compressed form) You’ll see the DEM and hillshade are rasters, and the raw lidar point data are in files with a .laz extension. The codes are tile number, tiled and compressed to a .laz format. We only have you download a small bit of data so that you get a bit of experience with the tool. This might help you remember its existence later, if you need it on another project. However, you may be put in a rather lengthy queue, so to avoid waiting, we’ve downloaded all the relevant data for the class project. It is on the L drive, in the 5295 directory (not the 5295share), under LiDAR. You should copy the DEM and hillshade, and the relevant laz/las files from the L drive directory to a new directory, in this example we’ll call it \LASData. Note that you don’t need all the .laz/.las point files that MnTOPO distributes, but only a subset of tiles, depending on your study area. You should refer to the image below, and only copy the files you need for your project area. The boundaries correspond to the tile borders, and the labels the .laz/.las file names. Also note, your working directory should NOT be on a network drive, e.g., the class L drive. LAS files are often quite large, and the overhead of copying and then writing back to the drive across a network is often too slow. Best to work on a local drive, that is, the drive on your computer, or a

Upload: duongnhi

Post on 13-Aug-2018

225 views

Category:

Documents


2 download

TRANSCRIPT

ESPM5295

16-Oct-17

1

IntroductiontoLiDAROurgoalsherearetointroduceyoutoLiDARdata,toshowyouhowtodownloaditforanareaofinterest,andtobetterunderstandthedataandusesthroughsomesimplemanipulations.Inourprojectwe’llbecalculatingbuildingandtreeheightsforyourprojectarea.ThestateonMinnesotahasflownLiDARfortheentirestate.DatamaybeinteractivelydownloadedviatheMNDNRMNTopoviewer(http://dnr.state.mn.us/maps/mntopo/index.html),orforlargerareasviatheMNGEOftpsite(ftp://ftp.lmic.state.mn.us/pub/data/elevation/lidar/).RasterDEMs,hillshades,contours,andthe“raw”dataor“pointcloud”datamaybedownloaded,inESRIgeodatabasesorincommonlysupportedformats. WewilldownloadLiDARdataandderivedlayersandpreparethemforinclusioninourCampusGIS.Wewillfirstworkwiththeprocessedlayers,andlatertherawdata,primarilyforbuildingheights.WeneedtomergetogetherseveraltilesforthecompleteSt.PaulCampus. ThisiscommonwhenworkingwithLiDAR. Ourindividualstudyareasaresmall,sowe’veonlyafewtiles.OpentheMnTOPOwebsite,andfamiliarizeyourselfwiththetoolsneartheupperright.Usethedefaultdisplayandthezoombuttonintheupperleft,andclick-hold-dragtopan,togettheapproximateCampusareadisplayed.First,tousethedownloaddatatool(diskdrivewitharrowicon,inthetoolbarrow,upper/left),specifyasmallpolygonthatiscenteredonyourindividualprojectarea.Downloadonlyonetileforeachofthefollowing:

• 1mdem,• 1mhillshade• therawlidarpointclouddata(thesewillbe.lasor.laz(acompressedform)

You’llseetheDEMandhillshadearerasters,andtherawlidarpointdataareinfileswitha.lazextension.Thecodesaretilenumber,tiledandcompressedtoa.lazformat.

Weonlyhaveyoudownloadasmallbitofdatasothatyougetabitofexperiencewiththetool.Thismighthelpyourememberitsexistencelater,ifyouneeditonanotherproject.However,youmaybeputinaratherlengthyqueue,sotoavoidwaiting,we’vedownloadedalltherelevantdatafortheclassproject.ItisontheLdrive,inthe5295directory(notthe5295share),underLiDAR.YoushouldcopytheDEMandhillshade,andtherelevantlaz/lasfilesfromtheLdrivedirectorytoanewdirectory,inthisexamplewe’llcallit\LASData.Notethatyoudon’tneedallthe.laz/.laspointfilesthatMnTOPOdistributes,butonlyasubsetoftiles,dependingonyourstudyarea.Youshouldrefertotheimagebelow,andonlycopythefilesyouneedforyourprojectarea.Theboundariescorrespondtothetileborders,andthelabelsthe.laz/.lasfilenames.Alsonote,yourworkingdirectoryshouldNOTbeonanetworkdrive,e.g.,theclassLdrive.LASfilesareoftenquitelarge,andtheoverheadofcopyingandthenwritingbacktothedriveacrossanetworkisoftentooslow.Besttoworkonalocaldrive,thatis,thedriveonyourcomputer,ora

ESPM5295

16-Oct-17

2

USBdrivepluggedintooneoftheports.

DisplaytheDEMandhillshadesurfaces.Thesearelargelyfromanautomatedprocessthatfirsttriestoidentifythe“bareearth,”orgroundonlyreturns,andthenbuildaDEMandahillshade.Noticetheoddshapes,sometimesliketriangles,onthehillshadesurfacewithinthebuildingfootprints.Theseareartifactsoflidardataprocessing.Thealgorithmshaveahardtimeidentifyingthegroundnearbuildingsperfectly,sothereareoftentriangularshapesonornearbuildings.Youalsoseearoughnessandoccasionalsmallbumpsovergrassorforestareas,thesearealsoartifactsoftheprocessing.

AlsonoticetheDEMrastersareinUTM15NAD83(1986).YouwillneedtotransformthemtoCORS96ifyouwishtoavoidthewarningsaboutdatumconflictswhendisplayedwithyourotherprojectdata.

YoucandoallthefollowingstepsinArcGIS,wewillbeusingLASTools,awidely-used,generalpurposelidarprocessingtoolboxthatismuchfasterthanprocessinginArc,andquiteflexible.TheUMNhasasitelicenceforLASTools,sowe’llbeusingitforthissmallexercise.Youshouldmaketwosub-directorieswithinyour\LasDatadirectory,onenamedbuildings,andonenamedtallveg,intowhichwe’llbesubsettingthelasdata.BecauseLASToolsismodular,andyouwanttobeabletoworkathomeoronothercomputers,wecancopythespecifictoolswe’llbeusingtothedirectorywithourdata.FindtheLASToolsdirectoryontheL:\5295directory,thenthe\binsubdirectory,cancopythelas2las.exeandlas2shp.exefilestoyourlocalworkingdirectory.Alsocopythecorresponding.txtfilesthatcontainthedocumentationforeachofthesetoolsWhenyou’redone,yourdirectoryshouldlooksomethinglikethiswindowbelow.

ESPM5295

16-Oct-17

3

YounoticeI’veconvertedcopiesofthe.lazto.lasfiles.Youdon’tneedto,butnoticethe.lazfilesaremuchsmallerthanthe.las.Becauselidardataareoftensolarge,thereisusuallyatradeoffbetweensavingspaceandprocessingspeed.We’reworkingwithasmallarea,soitdoesn’tmuchmatter,butinmanyrealprojectsitdoes.AlsonotethatIonlyshowasubsetofthe.lasfiles,yoursetwilldependonyourstudyarea.YoushouldknowafewmorethingsaboutLiDARdata.Remember,theseLiDARarefrompulsesoflightsentdownfromaplane,thenreflectedbackfromatarget.Precisegeometryallowsoperatorstodeterminethex,y,andzcoordinatestowithinafewinchesofeachobjectthatreflectsbackapulse.Therecanbemanyreturnsmeasuredfromeachpulse,althoughwe’remostofteninterestedinthefirstreturns,tomeasureobjectheights,andthelastreturns,tomeasuregroundelevation.Thedataareprocessedbeforethey’redelivered,andthecollectingorganizationusuallyappliesalgorithmstotrytodetectgroundhits(notalllastreturnsarefromtheground),objectheights(notallfirstreturnsarefromthetopsofobjects),andtoprovideotherinformationabouteachdatapoint.Mosttimeseachreturnpointcontainsinformationonthereturnnumber(first,last,orinbetween),thefeatureclassification(2=ground,4=mid-heightvegetation,5=highvegetation,6=building,9=water,0=unclassified),aswellasthescanangle,thestrengthofthereturnsignal,andotherinformationaboutthepoint.LASTools,andmostotherlidarprocessingtools,allowustoaccessthesedata.We’llusethecommandprompttorunLAStools.ThecommandpromptisfoundviatheWindowsStartbutton(pinkarrow,right),theninthe

ESPM5295

16-Oct-17

4

Accessoriesfolder–>CommandPrompt(greenarrowandcircled,atright)InWindows10,asinthelab,youclickonthesomewhatsimilariconinthelowerrightcorner,andtypeCMDinthesearchwindow,thenclickontheCMDcommandthatpopsup.Thiswillopenasmallwindowthatonlyallowsonlytextentry(seebelow).

Thepromptshowsthecurrentpathstring.Wanttosetthepathtoyourdatalocation.Firsttypeinthedriveletter,inmycasetheYdrive,soItypeinthedriveletterandthenhitreturntochangetothatdrive:Y:

Thepromptshouldnowshowthedrive,inmycase:Y:\IthenusetheCD(ChangeDirectory)commandtochangetheactivedirectory,typingin:CDdownloads\lasdataSothepromptnowbecomes:Y:\downloads\lasdataIcantypeDIR(fordirectory)andthenhitreturn,itshouldlistthedirectorycontents.IcancheckitagainsttheWindowsExplorerviewofthedirectory,showatthebottomofpage2,toverifyI’matthecorrectsubdirectory.Now,ontoprocessing.LASToolsisabitoldschool,youdon’thaveaccesstoaGUI,youspecifyoptionsthrough“flags”onacommandline.EachflaginLASToolsstartswithadash,e.g.,“-i”meansthefollowingtextspecifiestheinputfile(s).Thisisabitcumbersomeforsinglefileprocessing,butitisgreatfor

ESPM5295

16-Oct-17

5

writingsmallprogramstodorepetitivetasks.Anotherkeybitofinformationisthattheasterisk*standsfor“matcheverything,”andhelpswhenspecifyingmultiplefiles.Ifyou’vecopiedtheLASToolsprogramsfromtheCLDdrive,andareworkingathomeoranothernon-Skok35computer,you’llhavetotypesomethinglikethefollowingline,andenter:setPATH=%PATH%;c:\yourdirectory\lastools\binwherec:\yourdirectoryisthepathtothedirectoryonyourcomputerthatcontainsthelastoolsdirectory.Ifyou’reworkingin35Skok,ignorethis.Thefirstcommandwe’lltypeis:Las2las–i*.laz–odirbuildings–keep_class6Thisusesthelas2lastoolto:

• Readallthe.lazfilesasinput(-imeansinput,the*.lazusesthewildcardsymbol*tomatchanythingthatcomesbeforea.lazextension).NOTEHERE:IFI’vealreadyuncompressedmy.lazfilesto.lasfiles,IHAVETOSPECIFY-i*.lasastheinput

• Outputthemtothedirectorynamedbuildings(-odirbuildings),and• Onlykeeptheclasslabeled6(-keep_class6),inthiscasethepointsclassifiedasbuilding

pointsYoumaygetacommentsayingtheuseofLasToolsisunauthorized,ignoreit.Wedohavealicense,butsettingituprequiresafewmoresteps,andthechangestheymightwarnaboutareminor,anddon’tchangeouroutcome.WecanuseCDchangetothatbuildingsdirectoryafterthecommandruns,andverifythecommandworked:

Noticethefileshavethesamenameastheoriginals(that’swhyweputtheminaclearlylabeled

ESPM5295

16-Oct-17

6

sub-directory),butthatthey’remuchsmaller,thesubsetbuildingfileis16,337,316bytes(16.3Mb),whilethefulldatasetwasalmost166Mb;we’vesampledoutonlythebuildingreturns,andthefileislessthan10%oftheoriginalsize.Wecanapplyasimilarcommandtospecifykeepingonlythevegetationclasses(3,lowveg,4,mediumtrees,and5,hightrees):Las2las–i*.laz–odirtallveg–keep_class345Notetheoutputdirectoryissettotallveghere.Youshouldcheckyourselftomakesurethecommandworked,andnotethedecreaseinsize.ConverttheselaspointstoESRIshapefileswiththelas2shpcommand.Toconverttypein:las2shp–ibuildings\*.las–single_pointsandhitreturn.Again,youmaygetawarningthatyou’reunauthorized,andthey’readdingsmallerrorstothedata,youcanignorethemhere.Thecommandaccessesthelas2shpcommand(las2shp),tellsittouseall.lasfilesinthebuildingsdirectoryasinput(–ibuildings\*.las),andtooutputsingle-pointshapefiles(-single_points),notmultipointfiles,whichclusterpointsinblocks,reducingfilesize,butencumberingaccess.Verifytheabovecommandworked,firstbylookinginthebuildingsdirectoryandcheckingthatshapefile(s)appeared,andthenbydisplayingthedatainanArcMapview:Youcanseethepoints,hereinyellow,moreorlessmatchthebuildinglocations.Theslightmismatchisbecauseofbuildingleanintheaerialphotographs.Youmightrememberthatorthophotoscorrectalllocationsasiftheywereontheground,andthetopsofbuildingsaren’t.Thus,thetopsgetdisplaced,usuallyoutwardfromtheimagingcenterrelativetothecameraposition.

ESPM5295

16-Oct-17

7

That’swhyskyscrapersseemtoleaninmost“vertical”orthophotos.Nowweshouldlookatheights.First,weneedtocreateavariabletoholdoureventualheight,measuredfromthegroundtothetopoftheobject.Openthetableforeachofyourpointshapefiles,andaddanewfieldnamedzHeight,doubleorfloat,precision12,scale1.Thismaytakesometimeforeachtile,youcouldtrytousetheAddFieldcommandasanArcMapbatchjob.Youarestronglyencouragedtodothisandthefollowingoperationsasbatchjobs(seecourseresources,oraskAndyorPaulforhelp).Thiswillgreatlyeaseyourwork.Next,weneedtoextractheightsfromthepoints.ItisusuallymoreefficienttodoitasabatchjobwiththeAddGeometryAttributestool,specifymetersandsquaremetersforunits,andourprojectcoordinatesystem.Notethatthistoolwillalsoaddthexandycoordinatesforeachpoint.Whentheprocessisfinished,usetheidentifybuttontoqueryafewbuildingheights(zvalues).Remember,thevaluesareinmeters.Dothesevaluesmakesense?Arethebuildingsover200meters(650ft)tall?Whydoyouthinkyou’regettingthesevalues?TheZvaluerepresentstheorthometricheightofthetopofthebuilding.Thisistheheightrelativetoourstandardsurface,nearsealevel,andnotrelativetothelocalgroundsurface.Weneedtosubtractthelocalgroundsurfacefromthebuildingzvaluetogetbuildingheight.OnewayistoquerytheDEMrasterbeloweachpoint,andaddittothetablerecordforeachpoint.WecanthensubtracttheDEMheightfromthezvalueswecalculatedfromtheAddGeometryAttributes,andgetabuildingheight.TheExtractValuestoPointstool,foundatArcToolbox->SpatialAnalystTools->Extract->Extractvaluestopointsdoesjustthis.Specifyingtheinputandoutputswillqueryeachcellbeloweachpoint,andaddacolumntothenewdatalayerspecified.Thismaytakequitealongtime,sobepatient,andagain,thisprocesscanberunasabatchjobformultiplefiles.

ESPM5295

16-Oct-17

8

ThisgeneratesanewcolumnnamedRASTEVALthatcontainsthegroundelevationsnearateachpoint:(ignorethezheightvalueinthetableatleft,thisisfromatestrun,inyourfilesitwillbezeroornull/notassigned)Nowyoucancalculatethebuildingheightsforeachpoint.Youcandothismanually,butitisbettertodoitasabatchjobwiththeCalculateFieldcommand.Createanewfieldcalledsomethinglikebuild_hghtfortheheightabove-groundsampledateachpoint,andthenbatchjobthefieldcalculation.Whenyouaredone,youshouldhaveatablethatlookssomethingliketheonetotheright:Now,calculatetheaverageheightfrompointsamplesforoneofyourbuildings.Thereareseveralwaystodothis,anditwouldeasiestiswiththeSpatialJointool.However,itdoesn’tworkmuchofthetime,freezingup,orworse,returningerroneousanswers,withnowarningthatthevaluesarewrong.Thereisanalternativewhichappearstoworkinmostcases,thatinvolvesmultiplesteps.FirstapplytheIntersecttool,withtheinputbuildingpolygons,andtheprocessedLiDARpointfile.First,weneedpolygonsforabuildingslayer,withIDsyou’veassigned(typicallyshortinteger),andforclarity,abuildingname.Youshouldalreadyhavecreatedthisbuildinglayeraspartofyourdatabase.YoumayhavetodisplayboththeLiDARpointsandanimageofthestudyareawithyourbuilding,andadjustthebuildingfootprintpolygonabittoaccountforbuildinglean.

ESPM5295

16-Oct-17

9

Afterensuringyouhaveaproperbuildingsfile,readtheIntersecttool’sdocumentation.StarttheIntersecttool,andspecifyyourbuildingandprocessed(heightscalculated)LiDARpoints.IfyouspecifyAllforthejoinattributes,itwilljointheattributesbyspatiallocation,intoapointfile,withthebuildingassignedtoeachpoint.

Wecanseetheattributetableforthepointfeaturesbelow.Thelastthreecolumnsarefromthebuildingslayer,withthebuildingFID,ID,andname,andallthecolumnsbefore,fromFID*throughRASTERVAL,arefromthepointfile,includingtheheightforeachLiDARpointthatlandedonthebuilding.

ESPM5295

16-Oct-17

10

Nowweneedtoaggregatethepointsforeachbuilding.TheeasiestwayisthroughtheSummaryStatisticstool.Thissummarizedfeatures,andIcanassign“case”attributes.Thiswillcalculatethesummarystatisticsforeverydifferentvalueofthecaseattribute.IfImakethebuildingIDmycaseattribute,itwillcreateatablewithsummarystatisticsforeachuniquebuilding.Thetoolisshownbelow:HereI’vespecifiedmyintersectedbuilding/LiDARpointsetastheinput,anoutputtable,andthefield,statistics,andcaseattribute.Iamcalculatingthemeanheightforthebuilding.YoumightargueIwantthetallestpointforabuilding,butmostroofsdon’tvarymuchinheight,andIwasconcernedthatabuildingmighthaveatowerorscaffoldontop,andhencegetthealargeerror.Fortreecanopies,amaximumstatisticwouldprobablymakemoresense.Runningthiscreatesanoutputtable:NotethereisameanheightforeachcaseofthebuildingID.Icanthensimplyjointhistomybuildinglayerby

ESPM5295

16-Oct-17

11

theIDcolumn,andcopy/savethejoinedfiletogetmyheightforeachbuilding.Therearesomenuancesinapplying.Multi-leveledbuildingsmayhavetobesplitintothevariouspieces,andtheheightscalculatedseparatelytomakemuchsense.Ifthebuildingfootprintsaretoolarge,ortherearemanyerrorsinclassification,thentheremaybeabitofbiasdownward.Generally,theseerrorsappeartobesmallinourapplication,andthismeasurementisgoodenoughforouruse.Performtheseprocessingstepsforboththebuildingsandthecanopydatalayer,sothateachfeaturehasaLiDARheight.Asnotedearlier,youshouldprobablycalculatethemaximumstatisticinforthecanopydatalayer,andthemeanstatisticsforthebuildingslayer,butevaluateanddecideforyourself.TurninamapofshowingyoursubsetLiDARdataforyourprojectarea,yourbuildingpolygon,andlabeleachbuildingwithyourcalculatedaveragebuildingheights.Useanimageforthebackground,eitheroneofthehighresolutionimagesontheclassdrive,oroneoftheWMSlayers.Includetheusualtitle,legend,scale,andotherstandardmapelements.Dothissameexerciseforthetreesinyourprojectarea.Again,createandturninasecondmapofyourresults,withanimagebackground,thetreepolygons,labeledbyheight.