arcpy缩放至所选要素
# encoding: utf-8
#获取地图文档中的图层列表
#mxd可引用网络驱动器上的文档
import arcpy
from arcpy import mapping
mxdpath=r"C:\Users\h\Desktop\fp.mxd"
mxd=arcpy.mapping.MapDocument(mxdpath)
mxd.activeDataFrame.zoomToSelectedFeatures()
若mxd中没有选择的图层,则会缩放至全部要素的范围
设置数据框的范围
# encoding: utf-8 #获取地图文档中的图层列表 #mxd可引用网络驱动器上的文档 import arcpy from arcpy import mapping mxdpath=r"C:\Users\h\Desktop\fp.mxd" mxd=arcpy.mapping.MapDocument(mxdpath) df=mapping.ListDataFrames(mxd,"Crime")[0] layer=mapping.ListLayers(mxd,"Burglaries",df)[0] df.extent=layer.getSelectedExtent()
转载自:https://blog.csdn.net/A873054267/article/details/85869209