Skip to main content

PointGeometry

汇总

PointGeometry 对象是在给定比例处既无长度亦无面积的形状。

讨论

在许多地理处理工作流中,您可能需要使用坐标和几何信息运行特定操作,但不一定想经历创建新(临时)要素类、使用光标填充要素类、使用要素类,然后删除临时要素类的过程。 可以使用几何对象替代输入和输出,从而使地理处理变得更简单。 使用 GeometryMultipointPointGeometryPolygonPolyline 类可以从头开始创建几何对象。

在创建几何对象的过程中,将执行一个简化过程,以使几何根据其几何类型在拓扑上保持一致。 例如,将校正可能自相交的面,或包含错误环方向的面。 坐标可能会在几何空间参考的分辨率范围内移动。

可以使用以下运算符代替几何方法:

Python 运算符

几何方法

+

intersect

|

union

-

difference

^

symmetricDifference

==

equals

!=

not equals

例如,要联合两个几何对象, g3 = g1 | g2 等效于 g3 = g1.union(g2)

+ 运算符将使用第一个几何的几何类型 (dimension) 来确定输出的几何类型。

语法

PointGeometry(inputs, {spatial_reference}, {has_z}, {has_m}, {has_id})

名称 说明 数据类型

inputs

A Point object used to create the object.

Point

spatial_reference

(可选)

The spatial reference of the new geometry.

(默认值为 None)

SpatialReference

has_z

(可选)

Specifies whether the geometry will be z-enabled.

(默认值为 False)

Boolean

has_m

(可选)

Specifies whether the geometry will be m-enabled.

(默认值为 False)

Boolean

has_id

(可选)

Specifies whether the geometry will support point IDs.

(默认值为 False)

Boolean

属性

名称 说明 数据类型

JSON

(只读)

采用字符串形式的几何的 Esri JSON 制图表达。

提示:

通过 json 模块的 loads 函数,返回的字符串可转换至字典。

String

WKB

(只读)

OGC 几何的熟知二进制 (WKB) 表示。 该属性以连续字节流的形式提供几何值的可移植表示。

Bytearray

WKT

(只读)

OGC 几何的熟知文本 (WKT) 表示。 该属性以文本字符串的形式提供几何值的可移植表示。

几何中的所有真曲线都将在 WKT 字符串的近似曲线中进行增密。

String

area

(只读)

面要素的面积。 对于其他所有要素类型,面积为零。

Double

centroid

(只读)

如果质心位于要素之内或要素之上则为真;否则为标注点。

Point

extent

(读取和写入)

几何范围。

Extent

firstPoint

(只读)

几何的第一个坐标点。

Point

hasCurves

(只读)

指定几何是否具有曲线。

Boolean

hullRectangle

(只读)

凸包矩形坐标对的空格分隔字符串。

String

isMultipart

(只读)

指定几何的部分数是否大于 1。

Boolean

labelPoint

(只读)

标注位置所在的点。 该点始终位于要素之内或之上。

Point

lastPoint

(只读)

要素最后一个坐标。

Point

length

(只读)

线状要素的长度。 该计算将使用 2D 笛卡尔算法。

对于点和多点几何,长度为零。 对于面几何,长度将是边界的 2D 长度。

Double

length3D

(只读)

线状要素的 3D 长度。 该计算将使用 3D 笛卡尔算法。

对于点和多点几何,长度为零。 对于面几何,长度将是边界的 3D 长度。

注意:

该操作不执行水平和垂直坐标系之间的单位转换。 假设 x、y 和 z 坐标在同一线性单位中。

注意:

此属性仅适用于投影数据。

Double

partCount

(只读)

要素的几何部分数。

Integer

pointCount

(只读)

要素的总点数。

Integer

spatialReference

(只读)

几何的空间参考。

SpatialReference

trueCentroid

(只读)

要素的重心。

Point

type

(只读)

几何类型: polygonpolylinepointmultipoint

String

方法

angleAndDistanceTo(other, {method})

返回到点或面的角度和距离的元组。

名称 说明 数据类型

other

The second geometry. If the geometry is a polygon, the distance is measured to the centroid of the polygon.

PointGeometry

method

(可选)

Specifies the method that will be used to measure distance.

  • GEODESIC—The shortest line between any two points on the earth's surface on a spheroid (ellipsoid). One use for a geodesic line is to determine the shortest distance between two cities for an airplane's flight path. This is also known as a great circle line if based on a sphere rather than an ellipsoid.

  • GREAT_ELLIPTIC—The line on a spheroid (ellipsoid) defined by the intersection at the surface by a plane that passes through the center of the spheroid and the start and endpoints of a segment. This is also known as a great circle when a sphere is used.

  • LOXODROME—The line follows a single compass bearing, or azimuth. Great circle routes are often broken into a series of loxodromes, which simplifies navigation. This is also known as a rhumb line.

  • PLANAR—Planar measurements use 2D Cartesian mathematics to calculate lengths and areas. This option is only available when measuring in a projected coordinate system and the 2D plane of that coordinate system will be used as the basis for the measurements. Planar measurements reflect the projection of geographic data onto a 2D surface, and do not account for the curvature of the earth.

(默认值为 GEODESIC)

String

返回值

数据类型 说明

tuple

将一组角(以度为单位)和距离(以米为单位)返回到另一个点。

boundary()

构造几何边界。

边界运算符

返回值

数据类型 说明

Object

面的边界是折线。 折线的边界是多点,对应于线的端点。 点或多点的边界是空的点或多点。

buffer(distance)

在距几何的指定距离处构造一个面。

缓冲运算符

名称 说明 数据类型

distance

The buffer distance.

The buffer distance is in the same units as the geometry that is being buffered.

A negative distance can only be specified for a polygon geometry.

Double

返回值

数据类型 说明

Polygon

缓冲的面几何。

clip(envelope)

构造几何体与指定范围的交集。

裁剪运算符

名称 说明 数据类型

envelope

An Extent object used to define the clip extent.

Extent

返回值

数据类型 说明

Object

将输出几何体按指定范围进行裁剪。

contains(second_geometry, {relation})

指定基础几何是否包含比较几何。

contains 方法与 within 方法相反。

本图仅显示 True 关系。

可能的包含关系

名称 说明 数据类型

second_geometry

A second geometry.

Object

relation

(可选)

Specifies the spatial relationship type that will be used.

  • BOUNDARY—The relationship has no restrictions for interiors or boundaries.

  • CLEMENTINI— Interiors of geometries must intersect. This option is equivalent to specifying None. This is the default.

  • PROPER— Boundaries of geometries must not intersect.

(默认值为 None)

String

返回值

数据类型 说明

Boolean

返回此几何是否包含第二个几何。

convexHull()

构造具有最小边界多边形的几何,以便所有外角均为凸角。

凸包运算符

返回值

数据类型 说明

Object

生成的几何。 单个点的凸包为该点本身。

crosses(second_geometry)

指定两个几何是否相交于较小形状类型的几何。

如果两条折线仅共用公共点(至少有一个点不是端点),则这两条折线交叉。 如果折线和面在面的内部共享一条折线(不等于整条折线)或一个公共点(对于垂直线),那么该折线与面交叉。

本图仅显示 True 关系。

可能的交叉关系

名称 说明 数据类型

second_geometry

A second geometry.

Object

返回值

数据类型 说明

Boolean

返回两个几何是否相交于较小形状类型的几何。

difference(other)

构造一个几何,该几何仅由基础几何所特有、而其他几何所没有的区域组成。

下图显示当红色多边形为源几何时的结果:

差异运算符

名称 说明 数据类型

other

A second geometry.

Object

返回值

数据类型 说明

Object

生成的几何。

disjoint(second_geometry)

指定基础几何和比较几何是否具有公共点。

此方法返回 False 时,两个几何相交。

本图仅显示 True 关系。

可能的不相交关系

名称 说明 数据类型

second_geometry

A second geometry.

Object

返回值

数据类型 说明

Boolean

返回两个几何是否具有公共点。

distanceTo(other)

返回两个几何之间的最小距离。距离将采用几何空间参考的单位。如果两个几何相交,则最小距离为 0。

两个几何必须具有相同的投影。

名称 说明 数据类型

other

第二个几何。

Object

返回值

数据类型 说明

Double

两个几何之间的距离。

equals(second_geometry)

指定基础几何和比较几何是否具有相同的形状类型,并在平面中定义相同的点集。 这仅是 2D 的比较;已忽略 m 值和 z 值。

本图仅显示 True 关系。

可能的相等关系

名称 说明 数据类型

second_geometry

A second geometry.

Object

返回值

数据类型 说明

Boolean

返回两种几何是否具有相同的形状类型,并在平面中定义相同的点集。

getGeohash(precision)

将经纬度的地理坐标系坐标中的 PointGeometry 转换为精确到 geohash 格网中边界框内的任意精度的 geohash 字符串。

名称 说明 数据类型

precision

The precision length of the hash string that will be returned for the PointGeometry. The minimum length is 1 and the maximum length is 20.

(默认值为 8)

Integer

返回值

数据类型 说明

String

将根据输入点几何经纬度坐标和精度长度返回 geohash 字符串。

import arcpy

# Spatial reference set to GCS_WGS_1984
spatial_reference = arcpy.SpatialReference(4326)
pnt = arcpy.Point(-88.236, 40.096)
pnt_geometry = arcpy.PointGeometry(pnt, spatial_reference)
print(pnt_geometry.getGeohash(6))  # dp1k05

getPart({index})

如果指定了索引,则将返回几何特定部分的 Point 对象的 Array 对象。 如果未指定索引,则返回的 Array 对象将包含每个几何部分的 Point 对象的 Array

getPart 方法等同于建立对象索引;即 obj.getPart(0) 等同于 obj[0]

名称 说明 数据类型

index

(可选)

The index position of the geometry.

Integer

返回值

数据类型 说明

Array

生成的 Array 对象。

intersect(other, dimension)

构造一个几何,它是两个输入几何的几何交集。 不同的维数可用于创建不同的 shape 类型。

对于同一 shape 类型的两个几何体,其交集为仅包含原始几何重叠区域的几何。

相交运算符

为了更快地获取结果,请在调用 intersect 类之前先测试两个几何体是否 disjoint

名称 说明 数据类型

other

The second geometry.

Object

dimension

Specifies the topological dimension (shape type) of the resulting geometry.

  • 1—The geometry will be a zero-dimensional geometry (point or multipoint).

  • 2—The geometry will be a one-dimensional geometry (polyline).

  • 4—The geometry will be a two-dimensional geometry (polygon).

Integer

返回值

数据类型 说明

Object

作为两个输入几何体的交集的新几何体(点、多点、折线或面)。

move({dx}, {dy}, {dz})

沿 x、y 和 z 轴将几何移动指定的距离以创建新几何。

名称 说明 数据类型

dx

(可选)

The distance the geometry will be moved along the x-axis.

(默认值为 0.0)

Double

dy

(可选)

The distance the geometry will be moved along the y-axis.

(默认值为 0.0)

Double

dz

(可选)

The distance the geometry will be moved along the z-axis. The geometry must be z-aware and have z-values.

(默认值为 0.0)

Double

返回值

数据类型 说明

Geometry

沿 x、y 和 z 轴按指定距离移动的输出几何。

overlaps(second_geometry)

指定两个几何的交集是否具有与其中一个输入几何相同的形状类型,并且不等于任一输入几何。

本图仅显示 True 关系。

可能的叠置关系

名称 说明 数据类型

second_geometry

A second geometry.

Object

返回值

数据类型 说明

Boolean

返回两个几何的交集是否具有与其中一个输入几何相同的尺寸。

pointFromAngleAndDistance(angle, distance, {method})

使用指定的测量类型按给定的角度(以度为单位)和距离(采用几何空间参考的单位)返回点。

名称 说明 数据类型

angle

The angle in degrees to the returned point.

Double

distance

The distance in the units of the geometry's spatial reference to the returned point.

Double

method

(可选)

Specifies the method that will be used to measure distance.

  • GEODESIC—The shortest line between any two points on the earth's surface on a spheroid (ellipsoid). One use for a geodesic line is to determine the shortest distance between two cities for an airplane's flight path. This is also known as a great circle line if based on a sphere rather than an ellipsoid.

  • GREAT_ELLIPTIC—The line on a spheroid (ellipsoid) defined by the intersection at the surface by a plane that passes through the center of the spheroid and the start and endpoints of a segment. This is also known as a great circle when a sphere is used.

  • LOXODROME—The line follows a single compass bearing, or azimuth. Great circle routes are often broken into a series of loxodromes, which simplifies navigation. This is also known as a rhumb line.

  • PLANAR—Planar measurements use 2D Cartesian mathematics to calculate lengths and areas. This option is only available when measuring in a projected coordinate system and the 2D plane of that coordinate system will be used as the basis for the measurements. Planar measurements reflect the projection of geographic data onto a 2D surface, and do not account for the curvature of the earth.

(默认值为 GEODESIC)

String

返回值

数据类型 说明

PointGeometry

按给定的角度(以度为单位)和距离(以米为单位)返回点。

projectAs(spatial_reference, {transformation_name})

将几何从一个空间参考投影到另一个空间参考。

当几何对象和目标空间参考没有公共基准面时,请指定 transformation_name 参数值。 有关详细信息,请参阅 地理基准面变换ListTransformations

当满足以下条件时,将执行垂直变换:

  • 几何对象具有 z 坐标。

  • 几何对象的空间参考和 spatial_reference 参数值均具有垂直坐标系。

  • transformation_name 参数值为垂直变换。

transformation_name 参数值是垂直变换,并且几何对象和目标空间参考都没有垂直坐标系时,函数将运算失败,并显示 ValueError 异常。

如果几何对象或 spatial_reference 参数值具有 未知空间参考 ,则输出几何的空间参考将是 spatial_reference 参数值的空间参考。 不建议使用未知空间参考进行分析。

projectAs 方法不会修改 m 值(如果存在)。

名称 说明 数据类型

spatial_reference

The spatial reference to which the geometry will be projected. The value can be a SpatialReference object or the coordinate system name.

SpatialReference

transformation_name

(可选)

The geotransformation name.

With ArcGIS Pro, if you do not specify a transformation, none will be applied. With ArcGIS Server, if you do not specify a transformation, a fallback transformation will be applied.

String

返回值

数据类型 说明

Object

经投影的几何。

rotate({origin}, {rotation_angle})

将几何围绕指定原点旋转指定角度(以弧度表示)。

旋转相对于原点应用,以便几何围绕原点旋转。 原点的选择对于旋转几何的位置影响很大。

旋转不适用于 z 方向。

以下将介绍原点及其对输出的影响的一些可能的选择:

  • 原点位于几何外(不在几何内或接触几何)- 几何的位置将发生变化,但该几何与其他以相同方式旋转的几何的相对位置保持不变。 位置将围绕原点旋转。

    几何外的原点

  • 原点位于几何的质心(质心位于几何内部或接触几何)- 几何将围绕其质心旋转。

    几何质心处的原点

  • 原点位于几何的顶点 - 几何将围绕所选顶点旋转。

    几何顶点处的原点

名称 说明 数据类型

origin

(可选)

The origin of the transformation. The argument can be either an arcpy.Point object or an arcpy.PointGeometry object.

The default origin, arcpy.Point(0.0, 0.0), will usually be located outside the target geometry.

(默认值为 arcpy.Point(0.0, 0.0))

Point

rotation_angle

(可选)

The angle, in radians, to rotate the geometry around its origin.

The default rotation angle is 0.0 radians (no rotation).

(默认值为 0.0)

Float

返回值

数据类型 说明

Geometry

输入几何围绕指定原点旋转指定角度。

scale({origin}, {sx}, {sy}, {sz})

从指定的原点沿 x、y 和 z 轴按指定的因子缩放几何以创建新几何。 已变换点(或顶点)的位置由以下提供:

\(( \space (x \space - \space origin_x) \space * \space scale_x \space + \space origin_x, \space (y \space - \space origin_y) \space * \space scale_y \space + \space origin_y, \space (z \space - \space origin_z) \space * \space scale_z \space + \space origin_z \space )\)

相对于原点应用变换,以使原点保持静止,而几何围绕其扩展或收缩。 所生成几何的扩展或收缩位置和方向受到原点的显著影响。

以下将介绍原点及其对输出的影响的一些可能的选择:

  • 原点位于几何外(不在几何内或接触几何) - 几何的大小和位置将发生变化,但几何将保持与以相同方式缩放的其他几何的相对位置。 位置将远离原点扩展或向原点收缩。

    几何外的原点

  • 原点位于几何的质心(如果质心位于几何内部或接触几何)- 几何的大小将发生变化,但几何的位置将保持锚定在质心。 几何将围绕质心增大或收缩。

    几何质心处的原点

  • 原点位于几何的顶点 - 几何的大小将发生变化,但几何的位置将保持锚定在所选顶点。 几何将从所选顶点开始增长或向顶点收缩。

    几何顶点处的原点

名称 说明 数据类型

origin

(可选)

The origin of the transformation. The argument can be either an arcpy.Point object or an arcpy.PointGeometry object.

The default origin, arcpy.Point(0.0, 0.0, 0.0), will usually be located outside the target geometry.

(默认值为 arcpy.Point(0.0, 0.0, 0.0))

Point

sx

(可选)

The factor that will be used to scale the geometry along the x-axis.

(默认值为 1.0)

Double

sy

(可选)

The factor that will be used to scale the geometry along the y-axis.

(默认值为 1.0)

Double

sz

(可选)

The factor that will be used to scale the geometry along the z-axis. The geometry must be z-aware and have z-values.

(默认值为 1.0)

Double

返回值

数据类型 说明

Geometry

从指定原点沿 x、y 和 z 轴按指定因子缩放的输出几何。

symmetricDifference(other)

构造一个几何,该几何由两个几何的并集减去其交集形成。

两个输入几何必须为同一 shape 类型。

symmetricDifference 运算符

名称 说明 数据类型

other

A second geometry.

Object

返回值

数据类型 说明

Object

生成的几何。

toCoordString(notation)

PointGeometry 转换为所选的坐标系记法。

名称 说明 数据类型

notation

The coordinate system notation to be generated.

  • DD— Decimal degrees is used, for example, 34.05719570N 117.19647020W.

  • DDM— Degrees decimal minutes is used, for example, 34 03.43174200N 117 11.78821200W.

  • DMS— Degree Minute Seconds, is used, for example, 34 03 25.90452000N 117 11 47.29272000W.

  • GARS— Global Area Reference System is used, for example, 126LJ47. It is based on latitude and longitude, and it divides and subdivides the world into cells.

  • GEOREF— World Geographic Reference System is used, for example, EJCE4821203432.

  • MGRS— Military Grid Reference System is used, for example, 11SMT8186968515.

  • USNG— United States National Grid is used, for example, 11S MT 81869 68515.

  • UTM— Universal Transverse Mercator is used, for example, 11S 481868 3768515. It is based on zone number, MGRS latitude band, and the easting and northing planar coordinate pair in that zone.

  • UTMNS— Universal Transverse Mercator (no spaces) is used, for example, 11N4818683768515. It is based on zone number, hemisphere designator, and the easting and northing planar coordinate pair in that zone.

None

返回值

数据类型 说明

String

指定坐标系记法中的点。

touches(second_geometry)

指定几何的边界是否相交。

当两个几何的交集不为空,但它们内部的交集为空时,说明两个几何接触。 例如,仅当点与折线的一个终点重合时,才表示点与折线接触。

本图仅显示 True 关系。

可能的接触关系

名称 说明 数据类型

second_geometry

A second geometry.

Object

返回值

数据类型 说明

Boolean

返回几何的边界是否相交。

union(other)

构造一个几何,该几何是输入几何的并集。

两个几何必须具有同一形状类型。

结果是单个几何,它是两个输入几何的组合。 任一输入几何中的任何内容都将成为结果的一部分。 但是,两个几何共有的内容在结果中只出现一次。

输入几何的顺序对输出没有影响。

联合运算符

名称 说明 数据类型

other

The second geometry.

Object

返回值

数据类型 说明

Object

生成的几何。

within(second_geometry, {relation})

指定基础几何是否位于比较几何之内。

within 方法是与 contains 方法相反的运算符。

本图仅显示 True 关系。

可能的被包含关系

如果基础几何是这些几何的交集且其内部交集不为空,则基础几何位于比较几何之内。 within 方法是 Clementini 运算符,在空的基础几何中除外。

名称 说明 数据类型

second_geometry

A second geometry.

Object

relation

(可选)

Specifies the spatial relationship type that will be used.

  • BOUNDARY—The relationship has no restrictions for interiors or boundaries.

  • CLEMENTINI— Interiors of geometries must intersect. This option is equivalent to specifying None. This is the default.

  • PROPER— Boundaries of geometries must not intersect.

(默认值为 None)

String

返回值

数据类型 说明

Boolean

返回基础几何是否位于比较几何之内。

代码示例

PointGeometry 示例

从头开始创建点要素类。

import arcpy

# Create a spatial reference from a wkid
spatial_ref = arcpy.SpatialReference(32145)

# A list of coordinate pairs
feature_info = [[1, 2], [3, 5], [7, 3]]

# A list to hold the PointGeometry objects
features = []

# For each coordinate pair, create a PointGeometry object
for pt in feature_info:
    point = arcpy.Point(*pt)

    point_geometry = arcpy.PointGeometry(point, spatial_ref)
    features.append(point_geometry)

# Persist a copy of the PointGeometry objects using CopyFeatures
arcpy.management.CopyFeatures(features, "c:/geometry/f.gdb/points")