4

I am trying to create a Digital Earth Model (DEM) using ArcPy under ArcGIS Pro 2, but I am running into some problems.

I can generate a DEM within ArcGIS Pro by selecting only the ground points under LAS files in the LAS dataset properties, but when I try to run the same code within ArcPy, it generates a DEM using all the points.

Any ideas how you select the return point type in ArcPy?

Here is the code that I have used.

arcpy.conversion.LasDatasetToRaster(lasd, "Test_arcpy_dem", "ELEVATION", "BINNING AVERAGE LINEAR", "FLOAT", "CELLSIZE", 10, 1)

As I said, this generates two different outputs, depending if I am in ArcGIS Pro or not.

  • 1
    You need to create a LAS Dataset Layer pro.arcgis.com/en/pro-app/tool-reference/data-management/… to restrict the class codes then use that layer in your LAS dataset to raster. The workflow is the same in desktop resources.arcgis.com/en/help/main/10.2/index.html#//… to create a layer then use that layer in LAS dataset to raster resources.arcgis.com/en/help/main/10.2/index.html#//… – Michael Stimson May 31 '18 at 21:34
  • That worked perfectly. If you add your comment as an answer, I will select it. – user44796 Jun 1 '18 at 15:39
  • 2
    Here is the code that I used based on suggestions from @MichaelStimson. classCodes = [2]; return_Vals = ['Last Return','First of Many','Last of Many','Single Return','1','2','3','4']; dem_layer = arcpy.CreateUniqueName('dem_layer') ## new LAS dataset layer name; arcpy.MakeLasDatasetLayer_management(lasd, dem_layer,class_code=classCodes,return_values=return_Vals); arcpy.conversion.LasDatasetToRaster(dem_layer, "DEM", "ELEVATION", "BINNING AVERAGE LINEAR", "FLOAT", "CELLSIZE", 10, 1); Note: I marked end of line with semi-colon. Not needed. – user44796 Jun 1 '18 at 17:29
  • Did that work for you? By default return_values is everything so I think that parameter can be omitted, apart from that it looks good. – Michael Stimson Jun 3 '18 at 23:32
  • It did work for me. If you post it as the answer, I will upvote it. – user44796 Jun 4 '18 at 16:17
4

Whether you're working in ArcGIS Pro or Desktop to restrict the class types to ground classes (2 and 8 if present) you need to create a LAS dataset layer:

arcpy.MakeLasDatasetLayer_management(lasd, "LASD_Layer",class_code=[2,8])

which you can use in your LAS dataset to raster function:

arcpy.conversion.LasDatasetToRaster("LASD_Layer", "Test_arcpy_dem", "ELEVATION", "BINNING AVERAGE LINEAR", "FLOAT", "CELLSIZE", 10, 1)

In Desktop: create a LAS dataset layer and LAS dataset to raster.

If you don't already have ground/nonground classes you can use Classify LAS Ground (also in ArcGIS Pro) by Esri or a similar tool to classify ground in your LiDAR point cloud; automatic classification of ground/nonground is usually quite successful, unlike automatic building classification but that's wandering off-topic.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.