-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAutoSetPage.py
More file actions
43 lines (40 loc) · 1.4 KB
/
Copy pathAutoSetPage.py
File metadata and controls
43 lines (40 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python
# encoding: utf-8
'''
@author: Wanghan
@contact: panda@cug.edu.cn
@software: Pycharm
@file: AutoSetPage.py
@time: 2018/8/1 20:06
@desc:
'''
import arcpy
class AutoSetLayout(object):
__mxd = None
__df=None
__lyr =None
__currentObExtent =None
__outFolder =r'E:\OutPut'
__currentRow =None
def __init__(self,Mxd_File,dfName,lyrName):
self.__mxd =arcpy.mapping.MapDocument(Mxd_File)
self.__df = arcpy.mapping.ListDataFrames(self.__mxd,dfName)[0]
self.__lyr = arcpy.mapping.ListDataFrames(self.__mxd,lyrName,self.__dfNameMain)[0]
#根据唯一值字段筛选要素,返回要素记录
def GetGeoObject(self,Filed,FiledValue):
rows = arcpy.SearchCursor(self.__lyr,self.__df)
for row in rows:
fv = str(row.getValue(Filed))
if FiledValue == fv :
self.__currentRow = row
else :
self.__currentRow=None
continue
def ExportToJpeg(self,NameField):
if self.__currentRow !=None:
self.__currentObExtent = self.__currentRow.shape.extent
self.__df.panToExtent(self.__currentObExtent)
outFile = self.__outFolder +u"\\" + self.__currentRow.getValue(NameField) + ".jpeg"
arcpy.mapping.ExportToJPEG(self.__mxd,outFile,self.__df,resolution=300)
arcpy.RefreshActiveView()
arcpy.RefreshTOC()