Point

摘要

The point object is used frequently with cursors. Point features return a single point object instead of an array of point objects. All other feature types—polygon, polyline, and multipoint—return an array of point objects or an array containing multiple arrays of point objects if the feature has multiple parts.

讨论

A Point is not a geometry class, but is commonly used to construct geometry. In the example below, a Point is used to create a PointGeometry object.

point = arcpy.Point(25282, 43770)
ptGeometry = arcpy.PointGeometry(point)

语法

Point ({X}, {Y}, {Z}, {M}, {ID})
参数说明数据类型
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 关系。

Possible contains relationships
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 关系。

Possible crosses relationships
disjoint (second_geometry)

Indicates if the base and comparison geometries share no points in common.

Two geometries intersect if disjoint returns False.

本图仅显示 True 关系。

Possible disjoint relationships
equals (second_geometry)

Indicates if the base and comparison geometries are of the same shape type and define the same set of points in the plane. This is a 2D comparison only; M and Z values are ignored.

本图仅显示 True 关系。

Possible equals relationships
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 关系。

Possible overlaps relationships
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 关系。

Possible touches relationships
within (second_geometry)

Indicates if the base geometry is within the comparison geometry.

within is the opposite operator of contains.

本图仅显示 True 关系。

Possible within relationships

方法

clone (point_object)
参数说明数据类型
point_object

A point object.

Point
contains (second_geometry)
参数说明数据类型
second_geometry

A second geometry.

Object
返回值
数据类型说明
Boolean

A return Boolean value of True indicates this geometry contains the second geometry.

crosses (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.

disjoint (second_geometry)
参数说明数据类型
second_geometry

A second geometry.

Object
返回值
数据类型说明
Boolean

A return Boolean value of True indicates that the two geometries share no points in common.

equals (second_geometry)
参数说明数据类型
second_geometry

A second geometry.

Object
返回值
数据类型说明
Boolean

A return Boolean value of True indicates that the two geometries are of the same shape type and define the same set of points in the plane.

overlaps (second_geometry)
参数说明数据类型
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.

touches (second_geometry)
参数说明数据类型
second_geometry

A second geometry.

Object
返回值
数据类型说明
Boolean

A return Boolean value of True indicates the boundaries of the geometries intersect.

within (second_geometry)
参数说明数据类型
second_geometry

A second geometry.

Object
返回值
数据类型说明
Boolean

A return Boolean value of True indicates this geometry is contained within the second geometry.

代码示例

Point example

Create Point object and display its properties.

import arcpy

# Create point object
#
pnt = arcpy.Point(2000, 2500)

# Print point properties
print "Point properties"
print "\tID: %i" % pnt.ID
print "\tX:  %i" % pnt.X
print "\tY:  %i" % pnt.Y
Point example 2

Examine point objects in polygon array object, returned from geometry object.

import arcpy
from arcpy import env

# Set workspace
#
env.workspace = "C:/Data"

# Create cursor to retrieve Hawaii shape
#
cur = arcpy.SearchCursor("US_States.shp", '"STATE_NAME" = \'Hawaii\'')

for row in cur:
    # Get the geometry object from the shape field
    #
    geom = row.shape
    print "Number of Hawaiian islands: %i" % (geom.partCount)
    
    # GetPart returns an array of geometries if multi-part polygon
    #
    Hawaii = geom.getPart()
    
    # GetPart returns an array of point objects for each part.
    #
    for island in Hawaii:
        print "Vertices in island: %i" % island.count
        for pnt in island:
          print "Vertex ID: %i, X: %f, Y: %f" % (pnt.ID, pnt.X, pnt.Y) 

相关主题


7/10/2012