首页 > 其他分享 >【Arcpy】ArcGIS带鹰眼图的地图布局思路

【Arcpy】ArcGIS带鹰眼图的地图布局思路

时间:2022-12-16 20:33:25浏览次数:42  
标签:val format arcpy mapping 鹰眼 ArcGIS mxd Arcpy fld

 鹰眼图选中要素的符号如下图设置。

 

import arcpy

def GetFieldUniqueValue(inTable,inField):
    rows=arcpy.da.SearchCursor(inTable,inField)
    value_lst=[row[0].encode('gbk') for row in rows]
    return set(value_lst)

mxd = arcpy.mapping.MapDocument("CURRENT")
dfMain=arcpy.mapping.ListDataFrames(mxd)[0]
#数据图层--->乡镇国土变更
lyrData=arcpy.mapping.ListLayers(dfMain)[0]
#主数据框区域图层----村级
lyrMain=arcpy.mapping.ListLayers(dfMain)[1]
dfOverview=arcpy.mapping.ListDataFrames(mxd)[1]
#鹰眼数据框区域图层---->村级
lyrOverview=arcpy.mapping.ListLayers(dfOverview)[0]
#区域名字段
fld='ZLDWMC'

uniqueVals=GetFieldUniqueValue(lyrOverview,fld)

for val in uniqueVals:
    lyrData.definitionQuery="{0}='{1}'".format(fld,val)
    lyrMain.definitionQuery="{0}='{1}'".format(fld,val)
    arcpy.SelectLayerByAttribute_management(lyrMain,"NEW_SELECTION","{0}='{1}'".format(fld,val))
    dfMain.zoomToSelectedFeatures()
    arcpy.SelectLayerByAttribute_management(lyrOverview,"NEW_SELECTION","{0}='{1}'".format(fld,val))
    arcpy.SelectLayerByAttribute_management(lyrMain,"CLEAR_SELECTION")#reset sel
    #输出路径用英文路径
    mxd.saveACopy('C:\Users\Administrator\Desktop\sanmenpo\{}.mxd'.format(val),'10.1')
    arcpy.mapping.ExportToPDF(mxd, 'C:\Users\Administrator\Desktop\sanmenpo\{}.pdf'.format(val), 'PAGE_LAYOUT',
                          df_export_width=1600,
                          df_export_height=1200)
    lyrData.definitionQuery=""
    lyrMain.definitionQuery=""
    arcpy.SelectLayerByAttribute_management(lyrOverview,"CLEAR_SELECTION")#reset sel

 

标签:val,format,arcpy,mapping,鹰眼,ArcGIS,mxd,Arcpy,fld
From: https://www.cnblogs.com/yzhyingcool/p/16988243.html

相关文章