• 欢迎光临~

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

开发技术 开发技术 2022-12-16 次浏览

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

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

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:UsersAdministratorDesktopsanmenpo{}.mxd'.format(val),'10.1')
    arcpy.mapping.ExportToPDF(mxd, 'C:UsersAdministratorDesktopsanmenpo{}.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

 

程序员灯塔
转载请注明原文链接:【Arcpy】ArcGIS带鹰眼图的地图布局思路
喜欢 (0)