몇 년 전 같은 문제가있었습니다. 필터링 된 LAS 데이터 또는 기타 보조 데이터가 필요없는 솔루션이 있습니다. LiDAR 데이터에 액세스 할 수 있고 다른 리턴에서 DEM / DSM / DHM (이하 DEM, 표면 모델 명명법의 의미론에 대해 논하고 있지 않음)을 생성 할 수있는 경우 다음 스크립트가 유용 할 수 있습니다.
arcpy 스크립트는 3 개의 DEM을 수집하고 포레스트 폴리곤과 트리 포인트 셰이프 파일을 뱉어냅니다. 3 개의 DEM은 동일한 공간 분해능 (예 : 1 미터)과 범위를 가져야하며 첫 번째 반환, 마지막 반환 및 노출 된 접지를 나타냅니다. 채식 추출에 대한 매우 구체적인 매개 변수가 있었지만 다른 요구에 맞게 매개 변수를 변경할 수 있습니다. 이것이 파이썬 스크립팅에 대한 첫 번째 심각한 시도 였기 때문에 프로세스가 향상 될 수 있다고 확신합니다.
# Name: Veg_Extractor.py
# Date: 2013-07-16
# Usage: ArcMap 10.0; Spatial Analyst
# Input: 1 meter DEMs for first returns (DEM1), last returns (DEM2), and bare earth (BE)
# Output: forest polygon (veg with height > 4m) shapefile with holes > 500m removed;
# tree point (veg with height > 4m, crown radius of 9 cells) shapefile
# Notes: Raises error if input raster cell sizes differ
import arcpy, os
from arcpy import env
from arcpy.sa import *
# Check out any necessary licenses
arcpy.CheckOutExtension("spatial")
# Script arguments
dem1 = arcpy.GetParameterAsText(0) #input Raster Layer, First Return DEM
dem2 = arcpy.GetParameterAsText(1) #input Raster Layer, Last Return DEM
bare_earth = arcpy.GetParameterAsText(2) #input Raster Layer, Bare Earth DEM
outForest = arcpy.GetParameterAsText(3) #shapefile
outTree = arcpy.GetParameterAsText(4) #shapefile
# Make sure cell size of input rasters are same
arcpy.AddMessage("Checking cell sizes...")
dem1Xresult = arcpy.GetRasterProperties_management(dem1, "CELLSIZEX")
dem1Yresult = arcpy.GetRasterProperties_management(dem1, "CELLSIZEY")
dem2Xresult = arcpy.GetRasterProperties_management(dem2, "CELLSIZEX")
dem2Yresult = arcpy.GetRasterProperties_management(dem2, "CELLSIZEY")
beXresult = arcpy.GetRasterProperties_management(bare_earth, "CELLSIZEX")
beYresult = arcpy.GetRasterProperties_management(bare_earth, "CELLSIZEY")
dem1X = round(float(dem1Xresult.getOutput(0)),4)
dem1Y = round(float(dem1Yresult.getOutput(0)),4)
dem2X = round(float(dem2Xresult.getOutput(0)),4)
dem2Y = round(float(dem2Yresult.getOutput(0)),4)
beX = round(float(beXresult.getOutput(0)),4)
beY = round(float(beYresult.getOutput(0)),4)
if (dem1X == dem1Y == dem2X == dem2Y == beX == beY) == True:
arcpy.AddMessage("Cell sizes match.")
else:
arcpy.AddMessage("Input Raster Cell Sizes:")
arcpy.AddMessage("DEM1: (" + str(dem1X) + "," + str(dem1Y) + ")")
arcpy.AddMessage("DEM2: (" + str(dem2X) + "," + str(dem2Y) + ")")
arcpy.AddMessage(" BE: (" + str(beX) + "," + str(beY) + ")")
raise Exception("Cell sizes do not match.")
# Check map units
dem1_spatial_ref = arcpy.Describe(dem1).spatialReference
dem1_units = dem1_spatial_ref.linearUnitName
dem2_spatial_ref = arcpy.Describe(dem2).spatialReference
dem2_units = dem2_spatial_ref.linearUnitName
bare_earth_spatial_ref = arcpy.Describe(bare_earth).spatialReference
bare_earth_units = bare_earth_spatial_ref.linearUnitName
if (dem1_units == dem2_units == bare_earth_units) == True:
if dem1_units == "Meter":
area = "500 SquareMeters" #Area variable for meter
unit = 1 #meter
elif (dem1_units == "Foot_US") or (dem1_units == "Foot"):
area = "5382 SquareFeet" #Area variable for feet
unit = 3.28084 #feet in meter
else:
raise Exception("Units are not 'Meter', 'Foot_US', or 'Foot'.")
else:
raise Exception("Linear units do not match. Check spatial reference.")
# Local variables:
(workspace, filename) = os.path.split(outForest)
arcpy.env.workspace = workspace
arcpy.env.overwriteOutput = True
dem1 = Raster(dem1)
dem2 = Raster(dem2)
bare_earth = Raster(bare_earth)
nbr1 = NbrRectangle(3, 3, "CELL")
nbr2 = NbrRectangle(5, 5, "CELL")
nbr3 = NbrCircle(5, "CELL")
# Give units and multiplier
arcpy.AddMessage("Linear units are " + dem1_units + ". Using multiplier of " + str(unit) + "...")
arcpy.AddMessage("Processing DEMs...")
# Process: Raster Calculator (DEM1 - BE)
ndsm_dem1 = dem1 - bare_earth
# Process: Raster Calculator (DEM1 - DEM2)
d1_d2 = dem1 - dem2
# Process: Raster Calculator
threshold_d1d2 = (d1_d2 > (0.1 * unit)) & (ndsm_dem1 >= (4.0 * unit))
# Process: Focal Statistics (max 3x3)
focal_max1 = FocalStatistics(threshold_d1d2, nbr1, "MAXIMUM", "DATA")
# Process: Focal Statistics (majority 5x5)
focal_majority = FocalStatistics(focal_max1, nbr2, "MAJORITY", "DATA")
# Process: Con
con_ndsm_dem1 = Con(ndsm_dem1 >= (4.0 * unit), focal_majority, focal_max1)
focal_majority = None
focal_max1 = None
# Process: Focal Statistics (min 3x3)
focal_min1 = FocalStatistics(con_ndsm_dem1, nbr1, "MINIMUM", "DATA")
con_ndsm_dem1 = None
# Process: Focal Statistics (min 3x3)
veg_mask = FocalStatistics(focal_min1, nbr1, "MINIMUM", "DATA")
# Process: Focal Statistics (max R5)
focal_max2 = FocalStatistics(ndsm_dem1, nbr3, "MAXIMUM", "DATA")
arcpy.AddMessage("Calculating tree points...")
# Process: Raster Calculator
tree_points = (veg_mask == 1) & (ndsm_dem1 == focal_max2) & (ndsm_dem1 >= (4.0 * unit))
ndsm_dem1 = None
focal_max2 = None
# Process: Raster Calculator
tree_pick = Pick(tree_points == 1, 1)
tree_points = None
# Process: Raster to Polygon
arcpy.RasterToPolygon_conversion(tree_pick, workspace + "\\tree_poly.shp", "SIMPLIFY", "Value")
tree_pick = None
# Process: Feature To Point
arcpy.AddMessage("Writing tree points...")
arcpy.env.workspace = workspace #reset workspace
arcpy.env.overwriteOutput = True #reset overwrite permission
arcpy.FeatureToPoint_management(workspace + "\\tree_poly.shp", outTree, "CENTROID")
arcpy.AddMessage("Calculating forest polygons...")
# Process: Focal Statistics (max 3x3)
forests = FocalStatistics(veg_mask, nbr1, "MAXIMUM", "DATA")
veg_mask = None
# Process: Raster Calculator
forest_pick = Pick(forests == 1, 1)
# Process: Raster to Polygon
arcpy.RasterToPolygon_conversion(forest_pick, workspace + "\\forest_poly.shp", "SIMPLIFY", "Value")
# Process: Eliminate Holes > 500 sq m (5382 sq ft)
arcpy.AddMessage("Writing forest polygons...")
arcpy.EliminatePolygonPart_management(workspace + "\\forest_poly.shp", outForest, "AREA", area, "0", "CONTAINED_ONLY")
# Clean up
arcpy.AddMessage("Cleaing up...")
arcpy.Delete_management(workspace + "\\tree_poly.shp")
arcpy.Delete_management(workspace + "\\forest_poly.shp")