课本_第二章、arcpy开发入门

发布时间 2023-05-10 11:09:25作者: Agiser0

 

八股文--判断文件是否存在
1 result = ap.Exists(文件路径)  # 返回布尔值
2 print result

八股文--获取.shp文件中矢量要素数量(属性表的行数)

参考连接:Result—ArcMap | 文档 (arcgis.com)

1 count = ap.GetCount_management(图层名称)
2 #此处的count是使用  地理处理工具  后得到的  result对象
3 #直接返回值是  得到的结果 
4 #得到输出的消息数
5 count.outputCouunt
6 #得到输出结果
7 count.getOutput(0)  #得到第一个输出
8 int(count.getOutput(0))  #转换为整形

 

八股文--列出arctoolbox所有工具箱
1 for tb in ap.ListToolBoxes():
2     print(tb)

 

八股文--列出坐标系
1 srs = ap.ListSpatialReference()
2 3 #GCS坐标系
4 gcs = ...
5 #PCS坐标系
6 pcs = ...