Select to view content in your preferred language

Dynamically adding surface constraints to las datasets using ValueTable leads to wrong surface type

329
4
Jump to solution
10-23-2025 12:26 PM
SantiagoGonzalez_Arriola
Emerging Contributor

I'm creating LiDAR-derived DEMs for multiple different sites. Each site has a different project boundary (clip_shp) and they all share the same lake break lines I'm using for hydro flattening (replace_shp). 

I've built the following function to build the necessary value table to feed into a step involving arcpy.management.CreateLasDataset() so that the project boundary is used to Soft Clip the DEM, and the lakes are used as Soft Replace surfaces. 

def build_value_table(clip_shp: Path, replace_shp: Path):
    """Return arcpy.ValueTable ready for in_surface_constraints."""
    vt = arcpy.ValueTable()
    if clip_shp.exists():
        vt.addRow([str(clip_shp), "<None>", "softclip"])
        print(f"  added clip constraint: {clip_shp}")
    else:
        print(f"  clip shapefile missing – skipped: {clip_shp}")

    if replace_shp.exists():
        vt.addRow([str(replace_shp), "Shape", "softreplace"])
        print(f"  added replace constraint: {replace_shp}")
    else:
        print(f"  replace shapefile missing – skipped: {replace_shp}")
    return vt

 The las dataset is created as follows: 

    # 1  create LAS dataset with constraints & statistics
    arcpy.management.CreateLasDataset(
        input=las_files,
        out_las_dataset=lasd_path,
        folder_recursion="NO_RECURSION",
        in_surface_constraints=vt_constraints,
        spatial_reference=sr,
        compute_stats="COMPUTE_STATS",
        relative_paths="RELATIVE_PATHS"
    )

The resulting las datasets have the project boundary correctly set as a soft clip surface, but the lakes are also set to Soft Clip, where they should be Soft Replace.  

I've tried specifying the number of rows explicitly with vt = arcpy.ValueTable(3) but that leads to worse results (only the project boundary is added but as Anchor Points).  

I've hit a wall trying to troubleshoot.  Any help / advise is greatly appreciated! 

1 Solution

Accepted Solutions
DuncanHornby
MVP Notable Contributor

Sometimes it hard to discern the exact parameter order/structure a tool requires, especially when they take complex parameters like value tables.  A trick is to run the tool in ArcPro; set it up as you want creating the output you desire. Then in the History pane right click on the run tool and choose copy python command. Paste that into notepad and you see exactly how the tool was called, including how it structures any parameters.

View solution in original post

0 Kudos
4 Replies
DuncanHornby
MVP Notable Contributor

Sometimes it hard to discern the exact parameter order/structure a tool requires, especially when they take complex parameters like value tables.  A trick is to run the tool in ArcPro; set it up as you want creating the output you desire. Then in the History pane right click on the run tool and choose copy python command. Paste that into notepad and you see exactly how the tool was called, including how it structures any parameters.

0 Kudos
SantiagoGonzalez_Arriola
Emerging Contributor

Thanks you @DuncanHornby !!  This method revealed the mystery that even ESRI tech support is puzzled with at the time of posting.  The surface constraint type keywords published by ESRI for arcpy.management.CreateLasDataset() are wrong.  This method revealed Soft_Replace and Soft_Clip (instead of softreplace and sofclip as published in the documentation); also it's Shape.Z instead of Shape.  

Note that if no properties are defined for a surface constraint, it defaults to Soft_Clip with <None> as height source.  

DuncanHornby
MVP Notable Contributor

@SantiagoGonzalez_Arriola , nice one! If you go to the help file for the tool at the bottom of every page is a "Feedback on this topic?" link. This appears the only way that we the end user can inform ESRI that the help page is incorrect or missing something useful. You should submit via that link your discovery on the incorrect keywords and point them to this thread.

0 Kudos
SantiagoGonzalez_Arriola
Emerging Contributor
Thanks Duncan!

I have an open ticket with Tech Support (Canada), I will certainly let them
know of the keywords mismatch (we already suspected this was the case, even
guessed/tried some very close variants), and they'll escalate it to ESRI
(US) for correction.
0 Kudos