Point (arcpy)
摘要
点对象经常与光标配合使用。点要素将返回单个点对象而不是点对象数组。而其他要素类型(面、折线和多点)都将返回一个点对象数组,并且当这些要素具有多个部分时,则返回包含多个点对象数组的数组。
讨论
点并非几何类,但通常用于构造几何。在以下示例中,点用于创建 PointGeometry 对象。
point = arcpy.Point(25282, 43770)
ptGeometry = arcpy.PointGeometry(point)
语法
参数 | 说明 | 数据类型 |
X |
The X coordinate of the point. (默认值为 0.0) | Double |
Y |
The Y coordinate of the point. (默认值为 0.0) | Double |
Z |
The Z coordinate of the point. (默认值为 None) | Double |
M |
The M value of the point. (默认值为 None) | Double |
ID |
The shape ID of the point. (默认值为 0) | Integer |
属性
属性 | 说明 | 数据类型 |
ID (读写) |
An integer used to uniquely identify the point. | Integer |
M (读写) |
The measure value of the point. | Double |
X (读写) |
The horizontal coordinate of the point. | Double |
Y (读写) |
The vertical coordinate of the point. | Double |
Z (读写) |
The elevation value of the point. | Double |
方法概述
方法 | 说明 |
clone (point_object) |
Clone the point object. |
contains (second_geometry) |
Indicates if the base geometry contains the comparison geometry. contains is the opposite of within. 本图仅显示 True 关系。 |
crosses (second_geometry) |
Indicates if the two geometries intersect in a geometry of a lesser shape type. Two polylines cross if they share only points in common, at least one of which is not an endpoint. A polyline and an polygon cross if they share a polyline or a point (for vertical line) in common on the interior of the polygon which is not equivalent to the entire polyline. 本图仅显示 True 关系。 |
disjoint (second_geometry) |
Indicates if the base and comparison geometries share no points in common. Two geometries intersect if disjoint returns False. 本图仅显示 True 关系。 |
equals (second_geometry) |
指示原几何和参照几何的 shape 类型是否相同并在平面中定义相同点集。这仅是 2D 的比较;已忽略 M 值和 Z 值。 本图仅显示 True 关系。 |
overlaps (second_geometry) |
Indicates if the intersection of the two geometries has the same shape type as one of the input geometries and is not equivalent to either of the input geometries. 本图仅显示 True 关系。 |
touches (second_geometry) |
Indicates if the boundaries of the geometries intersect. Two geometries touch when the intersection of the geometries is not empty, but the intersection of their interiors is empty. For example, a point touches a polyline only if the point is coincident with one of the polyline end points. 本图仅显示 True 关系。 |
within (second_geometry) |
Indicates if the base geometry is within the comparison geometry. within is the opposite operator of contains. 本图仅显示 True 关系。 |
方法
参数 | 说明 | 数据类型 |
point_object |
A point object. | Point |
参数 | 说明 | 数据类型 |
second_geometry |
A second geometry. | Object |
数据类型 | 说明 |
Boolean |
A return Boolean value of True indicates this geometry contains the second geometry. |
参数 | 说明 | 数据类型 |
second_geometry |
A second geometry. | Object |
数据类型 | 说明 |
Boolean | A return Boolean value of True indicates the two geometries intersect in a geometry of a lesser shape type. |
参数 | 说明 | 数据类型 |
second_geometry |
A second geometry. | Object |
数据类型 | 说明 |
Boolean | A return Boolean value of True indicates that the two geometries share no points in common. |
参数 | 说明 | 数据类型 |
second_geometry |
A second geometry. | Object |
数据类型 | 说明 |
Boolean |
返回布尔值为 True 表示两个几何的 shape 类型相同并在平面中定义了相同点集。 |
参数 | 说明 | 数据类型 |
second_geometry |
A second geometry. | Object |
数据类型 | 说明 |
Boolean | A return Boolean value of True indicates the intersection of the two geometries has the same dimension as one of the input geometries. |
参数 | 说明 | 数据类型 |
second_geometry |
A second geometry. | Object |
数据类型 | 说明 |
Boolean | A return Boolean value of True indicates the boundaries of the geometries intersect. |
参数 | 说明 | 数据类型 |
second_geometry |
A second geometry. | Object |
数据类型 | 说明 |
Boolean | A return Boolean value of True indicates this geometry is contained within the second geometry. |
代码实例
创建点对象并显示其属性。
import arcpy
# Create point object
#
pnt = arcpy.Point(2000, 2500)
# Print point properties
print("Point properties:")
print(" ID: {0}".format(pnt.ID))
print(" X: {0}".format(pnt.X))
print(" Y: {0}".format(pnt.Y))
检查面数组对象中的点对象,这些点对象由几何对象所返回。
import arcpy
# Create cursor to retrieve Hawaii shape
#
fc = "c:/data/Hawaii.shp"
cur = arcpy.da.SearchCursor(fc, ["SHAPE@"])
for row in cur:
# Get the geometry object from the shape field
#
print("Number of Hawaiian islands: {0}".format(row[0].partCount))
# GetPart returns an array of point objects for each part.
#
for island in row[0].getPart():
print("Vertices in island: {0}".format(island.count))
for pnt in island:
print("X: {0}, Y: {1})".format(pnt.X, pnt.Y))