ArcGIS使用arcpy读取并处理矢量数据的属性

#coding=utf-8
import arcpy
import os
def file_name(file_dir):
    File_List = []
    for root, dirs, files in os.walk(file_dir):
        for file in files:
             if ("shp" == file[-3:]):
                File_List.append(file)            
    return File_List
input = "[目录]\\今政区地名.shp"
inputName = "[目录]\\省域.shp"
rows=arcpy.SearchCursor(inputName)#获取省域.shp属性表数据
for row in rows:#遍历省域.shp属性表各行数据
    ID = row.FID#根据省域.shp属性表字段获取数据
    Name = row.Pname
    arcpy.Select_analysis(input,"[目录]\\%s.shp" %(Name),""""所属省"LIKE'%s%%'""" %(Name[0:2]))#Select_analysis工具介绍在文末
    print(Name)
FList = file_name("[目录]")
ValuesList  = []
for i in range(len(FList)):
    print(FList[i])
    arcpy.AverageNearestNeighbor_stats("[目录]\\%s." %(FList[i]),"EUCLIDEAN_DISTANCE","GENERATE_REPORT","#")#AverageNearestNeighbor工具介绍在文末
    ValuesList = arcpy.GetMessages().splitlines()
    print(ValuesList[7])
    print(ValuesList[8])
    print("==============================")
print("END")

Select_analysis工具介绍 AverageNearestNeighbor工具介绍

  • 作者:seibert(联系作者)
  • 发表时间:2020-06
  • 版权声明:未经站长允许,不可转载
  • 公众号转载:请在文末添加作者公众号二维码
  • 评论

    可能感兴趣内容