ArcGIS for Desktop

  • 文档
  • 合约
  • 支持

  • My Profile
  • 帮助
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

专为贵组织打造的制图平台

ArcGIS for Desktop

全面的专业性 GIS

ArcGIS for Server

面向企业的 GIS

ArcGIS for Developers

用于构建位置感知应用程序的工具

ArcGIS Solutions

适用于行业的免费模板地图和应用程序

ArcGIS Marketplace

获取适用于组织的应用程序和数据

  • 文档
  • 合约
  • 支持
Esri
  • 登录
user
  • 我的个人资料
  • 登出

帮助

  • 主页
  • 入门
  • 制图
  • 分析
  • 管理数据
  • 工具
  • 更多...

MoveLayer

  • 摘要
  • 讨论
  • 语法
  • 代码实例

摘要

Provides the ability to move a layer to a specific location within a data frame or group layer in a map document (.mxd).

讨论

MoveLayer will move a layer within a data frame and also within group layers in the same data frame. The moved_layer and reference_layer must reside within the same data frame. A layer cannot be moved from one data frame to a different data frame even within the same map document. Add_Layer, Insert_Layer, and RemoveLayer functions can be used to accomplish this requirement.

语法

MoveLayer (data_frame, reference_layer, move_layer, {insert_position})
参数说明数据类型
data_frame

A reference to a DataFrame object within which the layer will be moved.

DataFrame
reference_layer

A reference to a Layer object representing an existing layer that determines the location in relation to where the layer will be moved.

Layer
move_layer

A reference to a Layer object representing the layer to be moved.

Layer
insert_position

A constant that determines the placement of the moved layer relative to the referenced layer.

  • AFTER —Inserts the new layer after or below the referenced layer
  • BEFORE —Inserts the new layer before or above the referenced layer

(默认值为 BEFORE)

String

代码实例

MoveLayer example:

The following script will move a layer called Rivers above a reference layer called Lakes. Both layers are in a data frame called County Maps.

import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "County Maps")[0]
for lyr in arcpy.mapping.ListLayers(mxd, "", df):
    if lyr.name.lower() == "rivers":
        moveLayer = lyr
    if lyr.name.lower() == "lakes":
        refLayer = lyr
arcpy.mapping.MoveLayer(df, refLayer, moveLayer, "BEFORE")
mxd.saveACopy(r"C:\Project\Project2.mxd")
del mxd
有关此主题的反馈?

ArcGIS for Desktop

  • 主页
  • 文档
  • 合约
  • 支持

ArcGIS 平台

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

关于 Esri

  • 关于我们
  • 招贤纳士
  • 内部人员博客
  • 用户大会
  • 开发者峰会
Esri
© Copyright 2016 Environmental Systems Research Institute, Inc. | 隐私政策 | 法律声明