# 读取几何

PointGeometry 要素将返回单个 Point 对象而不是点对象数组。所有其他要素类型（面、折线和多点）都将返回一个点对象数组，或者，如果要素具有多个部件，则返回包含多个点对象数组的数组。

## 使用几何令牌

SHAPE@

SHAPE@XY

SHAPE@TRUECENTROID

SHAPE@X

SHAPE@Y

SHAPE@Z

SHAPE@M

SHAPE@JSON

SHAPE@WKB

OGC 几何的熟知二进制 (WKB) 表示。 用于以可移植的方式将几何值表示为连续的字节流。

SHAPE@WKT

OGC 几何的熟知文本 (WKT) 表示。 用于以可移植的方式将几何值表示为文本字符串。

SHAPE@AREA

SHAPE@LENGTH

## 读取点几何

``````import arcpy
infc = arcpy.GetParameterAsText(0)
# Enter for loop for each feature
for row in arcpy.da.SearchCursor(infc, ["SHAPE@XY"]):
# Print x,y coordinates of each point feature
x, y = row[0]
print("{}, {}".format(x, y))``````

``````2.0 4.0
8.0 10.0
7.0 5.0``````

## 读取多点几何

``````import arcpy
infc = arcpy.GetParameterAsText(0)
# Enter for loop for each feature
for row in arcpy.da.SearchCursor(infc, ["OID@", "SHAPE@"]):
# Print the current multipoint's ID
print("Feature {}:".format(row[0]))
# For each point in the multipoint feature,
#  print the x,y coordinates
for pnt in row[1]:
print("{}, {}".format(pnt.X, pnt.Y))``````

``````Feature 0:
3.0 8.0
4.0 4.0
6.0 6.0
Feature 1:
5.0 9.0
8.0 10.0
Feature 2:
9.0 5.0``````

## 读取折线或面几何

``````import arcpy
infc = arcpy.GetParameterAsText(0)
# Enter for loop for each feature
for row in arcpy.da.SearchCursor(infc, ["OID@", "SHAPE@"]):
# Print the current polygon or polyline's ID
print("Feature {}:".format(row[0]))
partnum = 0
# Step through each part of the feature
for part in row[1]:
# Print the part number
print("Part {}:".format(partnum))
# Step through each vertex in the feature
for pnt in part:
if pnt:
# Print x,y coordinates of current point
print("{}, {}".format(pnt.X, pnt.Y))
else:
# If pnt is None, this represents an interior ring
print("Interior Ring:")
partnum += 1``````

``````Feature 0:
Part 0:
3.0 8.0
1.0 8.0
2.0 10.0
3.0 8.0
Feature 1:
Part 0:
5.0 3.0
3.0 3.0
3.0 5.0
5.0 3.0
Part 1:
7.0 5.0
5.0 5.0
5.0 7.0
7.0 5.0
Feature 2:
Part 0:
9.0 11.0
9.0 8.0
6.0 8.0
6.0 11.0
9.0 11.0
Interior Ring:
7.0 10.0
7.0 9.0
8.0 9.0
8.0 10.0
7.0 10.0``````