访问质心坐标相关数据
结果展示
代码
import arcpy
shppath =r"C:\Users\admin\Desktop\excelfile\a2.shp"
with arcpy.da.SearchCursor(shppath, ["SHAPE@","SHAPE@XY","SHAPE@TRUECENTROID","SHAPE@X","SHAPE@Y","SHAPE@Z","SHAPE@M",]) as cursor:
for row in cursor:
print("几何对象:",row[0],"质心 x,y 坐标:", row[1],"质心 x,y 坐标:" ,row[2],"双精度 x 坐标:",row[3],"双精度 y 坐标:",row[4],"双精度 z 坐标:",row[5],"双精度 m 值:",row[6])
访问几何的 Esri JSON 字符串
结果展示
由图可以看出json字段包括要素的坐标数据和坐标系数据
代码
import arcpy
shppath =r"C:\Users\admin\Desktop\excelfile\a2.shp"
with arcpy.da.SearchCursor(shppath, ["SHAPE@JSON"]) as cursor:
for row in cursor:
print("几何的 Esri JSON 字符串:",row[0])
访问几何的WKB(二进制)
结果展示
代码
import arcpy
shppath =r"C:\Users\admin\Desktop\excelfile\a2.shp"
with arcpy.da.SearchCursor(shppath, ["SHAPE@WKB"]) as cursor:
for row in cursor:
print("几何的WKB:",row[0])
访问几何的WKT(文本)
结果展示
代码
import arcpy
shppath =r"C:\Users\admin\Desktop\excelfile\a2.shp"
with arcpy.da.SearchCursor(shppath, ["SHAPE@WKT"]) as cursor:
for row in cursor:
print("几何的WKT:",row[0])
访问几何的面积和长度
结果展示
代码
import arcpy
shppath =r"C:\Users\admin\Desktop\excelfile\a2.shp"
with arcpy.da.SearchCursor(shppath, ["SHAPE@AREA","SHAPE@LENGTH"]) as cursor:
for row in cursor:
print("面积:",row[0],"长度:",row[1])