以往在使用ArcEngine获取一些要素类的信息时会显得比较麻烦,要安装一系列的IDE才能运行。现在arcpy提供了很多方便的方式,让我们简单的获取这些信息。
import arcpy
from arcpy import env
env.workspace=r”E:services行政图行政区划图mdb.mdb”
cur=arcpy.SearchCursor(“地级市”)
for row in cur:
aa=row.getValue(“name”)
print geo.crosses(geo)
print geo.pointCount
geo=row.shape
print geo.type
print str(geo.area)+”平方米”
X= geo.extent.XMax
x= geo.extent.XMin
Y= geo.extent.YMax
y= geo.extent.YMin
print “Feature Extent XMax:%f,XMin:%f,YMax:%f,YMin:%f
name = %s”%(X,x,Y,y,aa)
这一段简单代码可以获得要素的很多信息,运行结果如下:
False
4862
polygon
15586030950.0平方米
Feature Extent XMax:561217.386700,XMin:438694.728400,YMax:4454627.288400,YMin:4214799.890200
name = 通化市
False
3454
polygon
17449623902.2平方米
Feature Extent XMax:692747.793100,XMin:509392.880400,YMax:4433761.475000,YMin:4272649.487800
name = 白山市
False
8964
polygon
43251702636.4平方米
Feature Extent XMax:929714.117100,XMin:619026.299000,YMax:4623093.040500,YMin:4344136.815400
name = 延边州
False
2883
polygon
5147347078.16平方米
Feature Extent XMax:486605.246400,XMin:404842.759500,YMax:4478169.045900,YMin:4374643.472200
name = 辽源市
False
5171
polygon
14364101959.1平方米
Feature Extent XMax:481814.159300,XMin:281711.629300,YMax:4581489.577600,YMin:4433523.291600
name = 四平市
False
6250
polygon
20537846149.7平方米
Feature Extent XMax:585736.021600,XMin:383626.379900,YMax:4702643.501700,YMin:4481541.048800
name = 长春市
False
5142
polygon
27793495708.0平方米
Feature Extent XMax:661761.751400,XMin:470989.275100,YMax:4635967.577500,YMin:4404602.836900
name = 吉林市
False
4246
polygon
21157876140.8平方米
Feature Extent XMax:514896.548000,XMin:269634.424100,YMax:4735245.311100,YMin:4563868.004700
name = 松原市
False
3519
polygon
25722139555.9平方米
Feature Extent XMax:371936.168600,XMin:160304.426900,YMax:4821620.056300,YMin:4594704.065200
name = 白城市