arcpy缩放至要素的另一种方法

# 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]
query='NAME='+"'ds'"
layer.definitionQuery=query
df.extent=layer.getExtent()

基于layer.definitionQuery来实现

转载自:https://blog.csdn.net/A873054267/article/details/85869758

You may also like...