Difference between revisions of "XML Script Lidar and DTM Import"

From OCAD Wiki - English
Jump to navigation Jump to search
Line 13: Line 13:
 
This is what you need to do:
 
This is what you need to do:
  
*Create the folder sturcture first. '''[https://www.ocad.com/downloads/XML_LiDAR.zip Download]''' and unzip our folder structure in your chosen directory.
+
*Create the folder structure first. '''[https://www.ocad.com/downloads/XML_LiDAR.zip Download]''' and unzip our folder structure in your chosen directory.
 
*Create a new, empty OCAD File with the desired symbol set, map scale and georeferencing. The '''[[New_Map_Wizard|New Map Wizard]]''' can help you with that.
 
*Create a new, empty OCAD File with the desired symbol set, map scale and georeferencing. The '''[[New_Map_Wizard|New Map Wizard]]''' can help you with that.
 
*Save this file as ''Template.ocd'' (means overwrite the ''Template.ocd'' file in the folder structure).
 
*Save this file as ''Template.ocd'' (means overwrite the ''Template.ocd'' file in the folder structure).

Revision as of 12:17, 26 March 2021

This function is available in OCAD Mapping Solution.This function is available in OCAD Orienteering.

LiDAR data are invaluable for mapping, as highly accurate contour lines and base maps can be created.
But when processing LiDAR data (las or laz file format) and DTM for larger areas, a computer can quickly become overloaded because not enough RAM is available and crashes.
To avoid this, you have to work with XML scripts for larger projects. This may seem complicated at first glance, but don’t worry: All you have to do is copy code and make some adjustments.


LiDARImportXML.png

Huge areas can be calculated in one single step.


This is what you need to do:

  • Create the folder structure first. Download and unzip our folder structure in your chosen directory.
  • Create a new, empty OCAD File with the desired symbol set, map scale and georeferencing. The New Map Wizard can help you with that.
  • Save this file as Template.ocd (means overwrite the Template.ocd file in the folder structure).
  • Put your LiDAR files in the folder 0_LAZ.
  • Open the XML_Script.xml file with a text editor and adjust the file pathes in the document, e.g. from C:\Tmp\XML_LiDAR\Template.ocd to S:\O Map ZG\Template.ocd.
  • In the OCAD File menu, go to Execute XML Script and run the script.

Before you run the script with all your data, it's recommended to put only a few LiDAR files into the 0_LAZ folder and see if everything works. If it does, put all LiDAR files there and clean all folders from output data from the testrun.

The XML function for importing las/laz files and creating contour lines and vegetation map is also available in the OCAD Orienteering edition.

Example

This script imports laz data and create contour lines and the vegetation base map.
The single tiles are calculated separately and then cropped and merged together in the end.

<?xml version="1.0" encoding="ISO-8859-1"?>
<OcadScript>
  <!-- 1. step: import all laz files and create ocdDem and ocdLas tiles-->
  <File.Open>
    <File>C:\Tmp\XML_LiDAR\Template.ocd</File>
  </File.Open>
  
  <File.SaveAs>
    <File>C:\Tmp\XML_LiDAR\1_ocdDem\Map.ocd</File>  
  </File.SaveAs>
  
  <Dem.DemImport>
    <LasImport>
      <Directory>C:\Tmp\XML_LiDAR\0_LAZ\</Directory>  
    </LasImport>    
    <CreateOcdDem>
      <Enabled>true</Enabled>
      <Cellsize100>100</Cellsize100>
      <CreateVegetationBaseMap>false</CreateVegetationBaseMap>
      
      <LasDtm>
        <Enabled>true</Enabled>
        <Classification>
          <Unclassified>false</Unclassified>
          <Ground>true</Ground>
          <LowVegetation>false</LowVegetation>
          <MeanVegetation>false</MeanVegetation>
          <HighVegetation>false</HighVegetation>
          <Building>false</Building>
          <LowPoint>false</LowPoint>
          <Water>true</Water>
          <OverlapPoints>false</OverlapPoints>
          <Other>false</Other>
        </Classification>
        <ReturnType>1</ReturnType>
        <CreateAndLoadIntensityAndClassificationMap>false</CreateAndLoadIntensityAndClassificationMap>
      </LasDtm>
      
      <LasDsm>
        <Enabled>false</Enabled>
        <Classification>
          <Unclassified>false</Unclassified>
          <Ground>true</Ground>
          <LowVegetation>true</LowVegetation>
          <MeanVegetation>true</MeanVegetation>
          <HighVegetation>true</HighVegetation>
          <Building>true</Building>
          <LowPoint>true</LowPoint>
          <Water>true</Water>
          <OverlapPoints>false</OverlapPoints>
          <Other>false</Other>
        </Classification>
        <ReturnType>2</ReturnType>
        <CreateAndLoadIntensityAndClassificationMap>false</CreateAndLoadIntensityAndClassificationMap>
      </LasDsm>      
    </CreateOcdDem>  
      <CreateOcdLas>
        <Enabled>true</Enabled>
      </CreateOcdLas>
  </Dem.DemImport>
 
  <File.Save>
    <Enabled>true</Enabled>  
  </File.Save>
  <File.Close>
    <Enabled>true</Enabled>  
  </File.Close>

  <!-- 2. step: match height at tile borders-->  
  <File.Open>
    <File>C:\Tmp\XML_LiDAR\Template.ocd</File>
  </File.Open>
  <File.SaveAs>
    <File>C:\Tmp\XML_LiDAR\2_ocdDemMatching\Map_Matching.ocd</File>  
  </File.SaveAs>
  <Dem.MatchTiles>
    <InputFolder>C:\Tmp\XML_LiDAR\1_ocdDem\</InputFolder>  
    <OutputFolder>C:\Tmp\XML_LiDAR\2_ocdDemMatching\</OutputFolder>  
  </Dem.MatchTiles>
  <File.Save>
    <Enabled>true</Enabled>  
  </File.Save>
  <File.Close>
    <Enabled>true</Enabled>  
  </File.Close>

  <!-- 3. step: merge ocdDem tiles to 7000m x 7000m ocdDem tiles (5000m x 5000m + 1000m border around): -->    
  <File.Open>
    <File>C:\Tmp\XML_LiDAR\Template.ocd</File>
  </File.Open>
  <File.SaveAs>
    <File>C:\Tmp\XML_LiDAR\3_ocdDemMerging\Map_Merging.ocd</File>  
  </File.SaveAs>
  <Dem.MergeTiles>
    <InputFolder>C:\Tmp\XML_LiDAR\2_ocdDemMatching\</InputFolder>  
    <OutputFolder>C:\Tmp\XML_LiDAR\3_ocdDemMerging\</OutputFolder>  
    <TileSize>5000</TileSize>  
  </Dem.MergeTiles>
  <File.Save>
    <Enabled>true</Enabled>  
  </File.Save>
  <File.Close>
    <Enabled>true</Enabled>  
  </File.Close>

  <!-- 4. step: crop ocdDem tiles to 5000m x 5000m -->    
  <File.Open>
    <File>C:\Tmp\XML_LiDAR\Template.ocd</File>
  </File.Open>
  <File.SaveAs>
    <File>C:\Tmp\XML_LiDAR\4_ocdDem_Cropped\Map_Cropped.ocd</File>  
  </File.SaveAs>
  <Dem.CropTiles>
    <InputFolder>C:\Tmp\XML_LiDAR\3_ocdDemMerging\</InputFolder>  
    <OutputFolder>C:\Tmp\XML_LiDAR\4_ocdDem_Cropped\</OutputFolder>  
    <TileSize>5000</TileSize>  
  </Dem.CropTiles>
  <File.Save>
    <Enabled>true</Enabled>  
  </File.Save>
  <File.Close>
    <Enabled>true</Enabled>  
  </File.Close>  
  
  <!-- 5. step: create contour lines -->    
  <Dem.CreateContourLines>
    <Enabled>true</Enabled>  
    <TemplateFile>C:\Tmp\XML_LiDAR\Template.ocd</TemplateFile>
    <InputFolder>C:\Tmp\XML_LiDAR\4_ocdDem_Cropped\</InputFolder>  
    <OutputFolder>C:\Tmp\XML_LiDAR\5_CreateContourLines\</OutputFolder>  
    <TileSizeCropping>5000</TileSizeCropping>  
    <Merging>true</Merging>  
    <EquidistanceOriginal>500</EquidistanceOriginal>
    <CreateNotSmoothedContours>false</CreateNotSmoothedContours>
    <EquidistanceLevel1>250</EquidistanceLevel1>
    <EquidistanceLevel2>1250</EquidistanceLevel2>
    <EquidistanceLevel3>0</EquidistanceLevel3>
    <SymbolNumberLevel1>101000</SymbolNumberLevel1>
    <SymbolNumberLevel2>102000</SymbolNumberLevel2>
    <SymbolNumberLevel3>0</SymbolNumberLevel3>
    <CreateSmoothedContoursUsingTpi>true</CreateSmoothedContoursUsingTpi>
    <EquidistanceTpiOriginal>250</EquidistanceTpiOriginal>
    <EquidistanceTpiLevel1>250</EquidistanceTpiLevel1>
    <EquidistanceTpiLevel2>1250</EquidistanceTpiLevel2>
    <EquidistanceTpiLevel3>0</EquidistanceTpiLevel3>
    <SymbolNumberTpiLevel1>101000</SymbolNumberTpiLevel1>
    <SymbolNumberTpiLevel2>102000</SymbolNumberTpiLevel2>
    <SymbolNumberTpiLevel3>0</SymbolNumberTpiLevel3>
    <UseDifferentSymbolsForDepressions>false</UseDifferentSymbolsForDepressions>
    <SymbolNumberLevel1Depr>0</SymbolNumberLevel1Depr>
    <SymbolNumberLevel2Depr>0</SymbolNumberLevel2Depr>
    <SymbolNumberLevel3Depr>0</SymbolNumberLevel3Depr>
    <SymbolNumberTpiLevel1Depr>0</SymbolNumberTpiLevel1Depr>
    <SymbolNumberTpiLevel2Depr>0</SymbolNumberTpiLevel2Depr>
    <SymbolNumberTpiLevel3Depr>0</SymbolNumberTpiLevel3Depr>
    <ConvertTpiContoursToBezier>true</ConvertTpiContoursToBezier>
    <DeleteCombinedDemFile>true</DeleteCombinedDemFile>
    <MinimumContourValue>0</MinimumContourValue>
    <MaximumContourValue>0</MaximumContourValue>
    <IsMaxContourLength>false</IsMaxContourLength>
    <MaxContourLength>0</MaxContourLength>
  </Dem.CreateContourLines>

  <!-- 6. step: merge contour lines into one ocd file-->    
  <File.Open>
    <File>C:\Tmp\XML_LiDAR\Template.ocd</File>
  </File.Open>
  <File.SaveAs>
    <File>C:\Tmp\XML_LiDAR\6_ImportAllOcds\Contour Lines.ocd</File>  
  </File.SaveAs>
  <File.Import.Ocd>
    <Directory>C:\Tmp\XML_LiDAR\5_CreateContourLines\</Directory>
    <SymbolOption>0</SymbolOption>
    <ColorOption>0</ColorOption>
  </File.Import.Ocd>  
  <File.Save>
    <Enabled>true</Enabled>  
  </File.Save>
  <File.Close>
    <Enabled>true</Enabled>  
  </File.Close>

  <!-- 7. step: create vegetation base map (png file) for each ocdLas file-->    
  <File.Open>
    <File>C:\Tmp\XML_LiDAR\Template.ocd</File>
  </File.Open>
  
  <File.SaveAs>
    <File>C:\Tmp\XML_LiDAR\7_png\Map_Vegetation.ocd</File>  
  </File.SaveAs>
  
  <Dem.CreateVegetationBaseMap>
    <Enabled>true</Enabled>
    <InputFolder>C:\Tmp\XML_LiDAR\1_ocdDem\</InputFolder>  
    <OutputFolder>C:\Tmp\XML_LiDAR\7_png\</OutputFolder>  
      
    <CellSize>1</CellSize>
    
    <NeighborhoodKernelUndergrowth>3</NeighborhoodKernelUndergrowth>
    <ThresholdUndergrowthLow>0.00</ThresholdUndergrowthLow>
    <ThresholdUndergrowthHigh>0.00</ThresholdUndergrowthHigh>  
    <ThresholdUndergrowthSlow>+1.00</ThresholdUndergrowthSlow>
    <ThresholdUndergrowthDifficult>+1.00</ThresholdUndergrowthDifficult>
    
    <NeighborhoodKernelVegetation>5</NeighborhoodKernelVegetation>
    <ThresholdVegetationLow>0.30</ThresholdVegetationLow>
    <ThresholdVegetationHigh>3.00</ThresholdVegetationHigh>
    
    <ThresholdVegetationSlow>-0.40</ThresholdVegetationSlow>
    <ThresholdVegetationDifficult>-0.20</ThresholdVegetationDifficult>
    <ThresholdVegetationVeryDifficult>+0.20</ThresholdVegetationVeryDifficult>
    
    <ThresholdOverlapPointsLow>0.30</ThresholdOverlapPointsLow>    
    <ShowAreaWithNoData>false</ShowAreaWithNoData>
    <UseFilter>true</UseFilter>
    <LasClassification>
      <NeverClassified>false</NeverClassified>
      <Unclassified>false</Unclassified>
      <Ground>true</Ground>
      <LowVegetation>true</LowVegetation>
      <MediumVegetation>true</MediumVegetation>
      <HighVegetation>true</HighVegetation>
      <Building>false</Building>
      <LowPoint>false</LowPoint>
      <HighPoint>false</HighPoint>
      <Water>false</Water>
      <Railroad>false</Railroad>
      <Road>false</Road>
      <Overlap>false</Overlap>
      <WireGuard>false</WireGuard>
      <WireConductor>false</WireConductor>
      <TransmissionTower>false</TransmissionTower>
      <WireStructurConnector>false</WireStructurConnector>
      <Bridge>false</Bridge>
      <Other>false</Other>  
    </LasClassification>    
  </Dem.CreateVegetationBaseMap>
  
  <File.Save>
    <Enabled>true</Enabled>  
  </File.Save>
  
  <File.Close>
    <Enabled>true</Enabled>  
  </File.Close>
  
  <!-- 7. step: merge png files to bigger tiles-->    
  <File.Open>
    <File>C:\Tmp\XML_LiDAR\Template.ocd</File>
  </File.Open>
  
  <File.SaveAs>
    <File>C:\Tmp\XML_LiDAR\8_mergePNG\Map_mergeVegetation.ocd</File>  
  </File.SaveAs>
  
  <Dem.MergeRasterMapTiles>
    <Enabled>true</Enabled>
    <InputFolder>C:\Tmp\XML_LiDAR\7_png\</InputFolder>  
    <OutputFolder>C:\Tmp\XML_LiDAR\8_mergePNG\</OutputFolder>  
  </Dem.MergeRasterMapTiles>

  <File.Save>
    <Enabled>true</Enabled>  
  </File.Save>
  
  <File.Close>
    <Enabled>true</Enabled>  
  </File.Close>  
</OcadScript>