Select to view content in your preferred language

Setting elevation using arcpy

546
1
03-10-2023 11:25 AM
saldanax
Emerging Contributor

Hello! I am currently developing a standalone python script to create a 3D scene. The points that I am plotting have a height component relative to the ground. Currently, my default for ground elevation is set to absolute and I need to manually change it to relative to the ground. Any suggestions on how to this using arcpy? I've been searching but not much luck. Thanks! 

Tags (3)
0 Kudos
1 Reply
Andrew--Johnson
Esri Regular Contributor

Hi,

There is no out of the box property available but you can backdoor it by updating the CIM for the layer. Here's a sample that sets it to the geometry Z values. If you need to set it to a field just use $feature.fieldname instead of Shape.Z

 

# Reference a project, map, and layer using arcpy.mp
p = arcpy.mp.ArcGISProject('current')
m = p.listMaps('Scene')[0]
l = m.listLayers('FewPoints')[0]
# Return the layer's CIM definition
l_cim = l.getDefinition('V2')
# Set the layer elevation to relative to ground based on Z values
l_cim.featureElevationExpression="Shape.Z"
#Push the changes back to the layer
l.setDefinition(l_cim)

 

 

0 Kudos