LayerElevation

摘要

LayerElevation 类用于在地图中定义 3D 图层的高度特征。

说明

要在 3D 模式下显示空间数据,可以在局部或全球场景的 3D 图层类别中设置图层的高度选项。 这包括定义图层的 elevationModeverticalUnits 并且可选择定义 cartographicOffset

elevationMode 允许选择要素相对于地面自定义高程表面呈现的位置。 有关使用地面或自定义高程表面的更多示例,请参阅 ElevationSurface 类。 在调整相对于基本高度垂直绘制的要素时,会应用到制图偏移。 如果 Z 值的线性单位与 XY 值可能不同,则使用垂直单位属性。

有关在 ArcGIS Pro 中配置图层高程设置的详细信息,请查看定义图层的高度特征帮助主题。

注:

3D 图层可能支持所有高程模式,也可能不支持。 使用错误处理可为给定图层类型设置所需高程模式。 有关如何执行此操作,请参阅以下示例。

属性

属性说明数据类型
cartographicOffset
(可读写)

获取和设置制图偏移。 要调整相对于 elevationMode 值建立的基本高度垂直绘制的要素时,可以应用偏移。

Double
elevationMode
(可读写)

获取和设置控制图层高度的高程模式。 内容窗格中的 3D 图层类别支持 ON_THE_GROUNDABSOLUTE_HEIGHTON_CUSTOM_SURFACERELATIVE_TO_GROUNDRELATIVE_TO_SCENERELATIVE_TO_CUSTOM_SURFACE

String
verticalExaggeration
(可读写)

获取和设置垂直夸大。 所有要素都根据指定的值进行放大。 此值的单位与垂直单位相匹配。 仅当 elevationMode 设置为 ABSOLUTE_HEIGHTRELATIVE_TO_GROUNDRELATIVE_TO_CUSTOM_SURFACE 时适用。

Double
verticalUnits
(可读写)

获取或设置图层的垂直单位。 如果图层的数据源已定义垂直坐标系,则图层的高程单位与垂直坐标系的线性单位相同。

注:

图层属性对话框的高程类别中显示的垂直单位可能会显示“数据源垂直单位”的值,但 verticalUnits 属性将返回特定单位。

String

方法概述

方法说明
setElevationMode (elevation_mode, expression, surface)

图层的基本高度使用一个或多个参数配置,具体取决于指定的 elevation_mode

setVerticalUnits ({vertical_units})

字符串常量用于设置高程的垂直单位。 如果不存在垂直坐标系,建议垂直单位始终于图层的水平单位一致。 例如,有时可能出现以下情况:创建的数据集的水平线性单位为米,而垂直单位为英尺。

方法

setElevationMode (elevation_mode, expression, surface)
参数说明数据类型
elevation_mode

Below is a list of valid strings.

  • ABSOLUTE_HEIGHT For features that occur at a constant height above a datum, regardless of ground elevation, such as airplanes. In addition, you can add a vertical exaggeration to the absolute height. Use the Shape.Z keyword for the expression argument.
  • ON_CUSTOM_SURFACE For features that occur on a surface not represented by ground level, such as a well site intersection on a subsurface geologic plane. You can choose a custom elevation surface from a list of defined surfaces in the scene.
  • ON_THE_GROUND For features that are situated at ground level, such as trees.
  • RELATIVE_TO_CUSTOM_SURFACE Where additional height values are added to the feature's location on a custom surface. You need a custom elevation surface to use this option. Use the feature's Z values or use the Feature Z profile to create an Arcade expression to adjust feature Z values.
  • RELATIVE_TO_GROUND For features that are placed at a known height above the ground, such as security camera positions on the side of a building. Use the feature's Z values or use the Feature Z profile to create an Arcade expression to adjust feature Z values.
  • RELATIVE_TO_SCENE For features that know where they are compared to the scene. These features align to the ground and 3D objects such as extruded polygons or buildings.
String
expression

An optional VB Script or Arcade expression to be applied depending on the specified elevation_mode.

注:

VB Script is deprecated in Windows. It is recommended to use Arcade.

String
surface

An optional ElevationSurface to be applied depending on the specified elevation_mode.

Object
setVerticalUnits ({vertical_units})
参数说明数据类型
vertical_units

Below is a list of valid strings.

  • FEETFeet
  • KILOMETERSKilometers
  • METERSMeters
  • MILESMiles
  • YARDSYards

(默认值为 METERS)

String

使用 3D 数据时,定义垂直坐标系至关重要。 如果图层的数据源已定义垂直坐标系,则图层的高程单位与垂直坐标系的线性单位相同。

代码示例

LayerElevation 示例 1

以下脚本将迭代场景中的 3D 图层并将其高程模式设置为在地面上

import arcpy

aprx = arcpy.mp.ArcGISProject("C:/projects/redlands/redlands.aprx")
m = aprx.listMaps("Scene")[0]
for lyr in m.listLayers():
    e = lyr.elevation
    # Use try/except for layers that support on the ground and 
    # skip over layers that do not support this elevation mode
    try:
        e.setElevationMode('ON_THE_GROUND')
    except Exception as e:
        print(f"An error occurred: {e} for {lyr.name}")
aprx.save()
LayerElevation 示例 2

以下脚本将迭代场景中的 3D 图层并将其高程模式设置为相对于自定义表面,Arcade 表达式设置为 50。

import arcpy

aprx = arcpy.mp.ArcGISProject("C:/projects/redlands/redlands.aprx")
m = aprx.listMaps("Scene")[0]
for lyr in m.listLayers():
    e = lyr.elevation
    # Use try/except for layers that support on the ground and 
    # skip over layers that do not support this elevation mode
    try:
        e.setElevationMode('RELATIVE_TO_CUSTOM_SURFACE','50',s)
    except Exception as e:
        print(f"An error occurred: {e} for {lyr.name}")
aprx.save()
LayerElevation 示例 3

以下脚本将迭代场景中的 3D 图层并将其高程模式设置为基于要素 Z 值的绝对高度

import arcpy

aprx = arcpy.mp.ArcGISProject("C:/projects/redlands/redlands.aprx")
m = aprx.listMaps("Scene")[0]
for lyr in m.listLayers():
    e = lyr.elevation
    # Use try/except for layers that support on the ground and 
    # skip over layers that do not support this elevation mode
    try:
        e.setElevationMode('ABSOLUTE_HEIGHT', 'Shape.Z')
    except Exception as e:
        print(f"An error occurred: {e} for {lyr.name}")
aprx.save()
LayerElevation 示例 4

以下脚本将迭代场景中的 3D 图层并将制图偏移设置为 100(如果当前偏移为 0)。

import arcpy

aprx = arcpy.mp.ArcGISProject("C:/projects/redlands/redlands.aprx")
m = aprx.listMaps("Scene")[0]
for lyr in m.listLayers():
    e = lyr.elevation
    if e.cartographicOffset == 0:
        e.cartographicOffset = 100
aprx.save()