ArcGIS for Desktop

  • 文档
  • 合约
  • 支持

  • My Profile
  • 帮助
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

专为贵组织打造的制图平台

ArcGIS for Desktop

全面的专业性 GIS

ArcGIS for Server

面向企业的 GIS

ArcGIS for Developers

用于构建位置感知应用程序的工具

ArcGIS Solutions

适用于行业的免费模板地图和应用程序

ArcGIS Marketplace

获取适用于组织的应用程序和数据

  • 文档
  • 合约
  • 支持
Esri
  • 登录
user
  • 我的个人资料
  • 登出

帮助

  • 主页
  • 入门
  • 制图
  • 分析
  • 管理数据
  • 工具
  • 更多...

Polyline

  • 摘要
  • 讨论
  • 语法
  • 属性
  • 方法概述
  • 方法
  • 代码实例

摘要

折线对象是由一个或多个路径定义的形状,其中路径是指一系列相连线段。

讨论

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

语法

 Polyline  (inputs, {spatial_reference}, {has_z}, {has_m})
参数说明数据类型
inputs

The coordinates used to create the object. The datatype can be either Point or Array objects.

Object
spatial_reference

The spatial reference of the new geometry.

(默认值为 None)

SpatialReference
has_z

The Z state: True for geometry if Z is enabled and False if it is not.

(默认值为 False)

Boolean
has_m

The M state: True for geometry if M is enabled and False if it is not.

(默认值为 False)

Boolean

属性

属性说明数据类型
JSON
(只读)

返回一个字符串形式的几何 Esri JSON 制图表达。

提示:

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

String
WKB
(只读)

返回 OGC 几何的熟知二进制 (WKB) 制图表达。 该存储类型将几何值表示为不间断的字节流形式。

Bytearray
WKT
(只读)

返回 OGC 几何的熟知文本 (WKT) 制图表达。其将几何值表示为文本字符串。

String
area
(只读)

面要素的面积。其他所有要素类型为空。

Double
centroid
(只读)

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

Point
extent
(读写)

几何范围。

Extent
firstPoint
(只读)

第一个几何坐标点。

Point
hullRectangle
(只读)

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

String
isMultipart
(只读)

如果此几何的部分数大于一,则为 True。

Boolean
labelPoint
(只读)

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

Point
lastPoint
(只读)

要素的最后一个坐标。

Point
length
(只读)

线状要素的长度。点和多点要素类型为零。

Double
length3D
(读写)

线状要素的 3D 长度。点和多点要素类型为零。

Double
partCount
(只读)

要素几何部分的数目。

Integer
pointCount
(只读)

要素的总点数。

Integer
spatialReference
(只读)

几何的空间参考。

SpatialReference
trueCentroid
(只读)

要素的重心。

Point
type
(只读)

几何类型:面、折线、点、多点、多面体、尺寸或注记。

String

方法概述

方法说明
angleAndDistanceTo (other, {method})

使用测量类型将一组角和距离返回到另一个点。

boundary ()

构造几何边界。

边界运算符
buffer (distance)

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

缓冲运算符
clip (envelope)

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

裁剪运算符
contains (second_geometry)

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

包含与在内部相反。

本图仅显示 True 关系。

可能的包含关系
convexHull ()

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

凸包运算符
crosses (second_geometry)

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

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

本图仅显示 True 关系。

可能的交叉关系
cut (cutter)

将该几何分割到剪切折线的左右两侧。

剪切折线或面时,会从其与剪切折线的相交处将其分割。每一段被分类为剪切线的左侧或右侧。该分类基于剪切线的方向。目标折线中不与剪切折线相交的部分将作为该输入折线结果的右侧部分返回。如果未对几何进行剪切,则左侧几何将为空 (None)。

剪切运算符
densify (type, distance, deviation)

使用添加的折点 创建新几何。

difference (other)

构造一个几何体,该几何体仅由基础几何所特有、而其他几何所没有的区域组成。下图显示当红色多边形为源几何时的结果。

不同运算符
disjoint (second_geometry)

指明基础几何和比较几何是否未共用任何点。

如果 disjoint 返回 False,则两个几何相交。

本图仅显示 True 关系。

可能的不相交关系
distanceTo (other)

返回两个几何之间的最小距离。如果两个几何相交,则最小距离为 0。

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

equals (second_geometry)

指示原几何和参照几何的 shape 类型是否相同并在平面中定义相同点集。这仅是 2D 的比较;已忽略 M 值和 Z 值。

本图仅显示 True 关系。

可能的相等关系
generalize (max_offset)

使用指定的最大偏移容差来创建一个简化几何。

getArea ({type}, {units})

使用测量类型返回要素的面积。

getLength ({measurement_type}, {units})

使用测量类型返回要素的长度。

getPart ({index})

返回几何特定部分的点对象数组,或包含多个数组(每个数组对应一个部分)的数组。

intersect (other, dimension)

构造作为两个输入几何交集的几何体。不同的维数可用于创建不同的 shape 类型。

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

相交运算符

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

measureOnLine (in_point, {as_percentage})

从此条线的起点向 in_point 返回一个测量值。

overlaps (second_geometry)

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

本图仅显示 True 关系。

可能的叠置关系
pointFromAngleAndDistance (angle, distance, {method})

使用指定的测量类型按给定的角度(以度为单位)和距离(以米为单位)返回点。

positionAlongLine (value, {use_percentage})

返回线上距线起点指定距离处的点。

projectAs (spatial_reference, {transformation_name})

定义几何投影,并应用相应的地理变换。

要进行投影,几何体需要具有一个空间参考且不具有 UnknownCoordinateSystem。传递到该方法的新空间参考系统参数定义了一个输出坐标系。如果任一空间参考未知,坐标将不会发生更改。ProjectAs 方法并不更改 Z 值和测量值。

queryPointAndDistance (in_point, {as_percentage})

在折线上找到离 in_point 最近的点,并确定这两点间的距离。同时返回关于 in_point 位于线的哪一侧以及最近点沿线的距离。

segmentAlongLine (start_measure, end_measure, {use_percentage})

在起始测量值和结束测量值之间返回 Polyline。虽然与 Polyline.positionAlongLine 相似,但是会在折线的两点之间(而不是在单点)返回折线段。

snapToLine (in_point)

基于以该几何作为捕捉目标的 in_point 返回一个新点。

symmetricDifference (other)

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

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

symmetricDifference 运算符
touches (second_geometry)

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

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

本图仅显示 True 关系。

可能的接触关系
union (other)

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

要合并的两个几何必须为同一 shape 类型。

联合运算符
within (second_geometry)

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

被包含是与包含相反的运算符。

本图仅显示 True 关系。

可能的被包含关系

方法

angleAndDistanceTo (other, {method})
参数说明数据类型
other

The second geometry.

PointGeometry
method

PLANAR measurements reflect the projection of geographic data onto the 2D surface (in other words, they will not take into account the curvature of the earth). GEODESIC, GREAT_ELLIPTIC, LOXODROME, and PRESERVE_SHAPE measurement types may be chosen as an alternative, if desired.

  • GEODESIC —The shortest line between any two points on the earth's surface on a spheroid (ellipsoid). One use for a geodesic line is when you want 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 —A loxodrome is not the shortest distance between two points but instead defines the line of constant 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.
  • PRESERVE_SHAPE —This type calculates the area or length of the geometry on the surface of the earth ellipsoid, for geometry defined in a projected or geographic coordinate system. This option preserves the shape of the geometry in its coordinate system.

(默认值为 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 against a polygon geometry.

Double

返回值

数据类型说明
Polygon

缓冲的面几何。

clip (envelope)
参数说明数据类型
envelope

An extent object used to define the clip extent.

Extent

返回值

数据类型说明
Object

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

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

A second geometry.

Object

返回值

数据类型说明
Boolean

返回布尔值 True 表示该几何包含第二个几何。

convexHull ()

返回值

数据类型说明
Object

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

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

A second geometry.

Object

返回值

数据类型说明
Boolean

返回布尔值为 True 指明两个几何相交于较小形状类型的几何。

cut (cutter)
参数说明数据类型
cutter

The cutting polyline geometry.

PolyLine

返回值

数据类型说明
Geometry

包含两个几何的列表。

densify (type, distance, deviation)
参数说明数据类型
type

The type of densification, DISTANCE, ANGLE, or GEODESIC.

  • DISTANCE —Creates a new feature that is a piecewise linear approximation of the input.
  • ANGLE —Creates a new feature that is a piecewise linear approximation of the input. Vertices are introduced at points where the angle between tangents at those points is the provided angle.
  • GEODESIC —Densifies and reshapes segments between input vertices so that the output segments follow the shortest ground path connecting input vertices.
String
distance

The maximum distance between vertices. The actual distance between vertices will usually be less than the maximum distance as new vertices will be evenly distributed along the original segment.

If using a type of DISTANCE or ANGLE, the distance is measured in the units of the geometry's spatial reference. If using a type of GEODESIC, the distance is measured in meters.

Double
deviation

Densify uses straight lines to approximate curves. You use deviation to control the accuracy of this approximation. The deviation is the maximum distance between the new segment and the original curve. The smaller its value, the more segments will be required to approximate the curve.

If using a type of DISTANCE, the deviation is measured in the units of the geometry's spatial reference. If using a type of ANGLE, the deviation is measured in radians. If using a type of GEODESIC, the deviation is not used.

Double

返回值

数据类型说明
Geometry

增密几何。

difference (other)
参数说明数据类型
other

A second geometry.

Object

返回值

数据类型说明
Object

生成的几何。

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

A second geometry.

Object

返回值

数据类型说明
Boolean

返回布尔值 True 表示两个几何未共用任何点。

distanceTo (other)
参数说明数据类型
other

A second geometry.

Object

返回值

数据类型说明
Double

两个几何之间的距离。

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

A second geometry.

Object

返回值

数据类型说明
Boolean

返回布尔值为 True 表示两个几何的 shape 类型相同并在平面中定义了相同点集。

generalize (max_offset)
参数说明数据类型
max_offset

The maximum offset tolerance.

Double

返回值

数据类型说明
Geometry

概化的几何。

getArea ({type}, {units})
参数说明数据类型
type

PLANAR measurements reflect the projection of geographic data onto the 2D surface (in other words, they will not take into account the curvature of the earth). GEODESIC, GREAT_ELLIPTIC, LOXODROME, and PRESERVE_SHAPE measurement types may be chosen as an alternative, if desired.

  • GEODESIC —The shortest line between any two points on the earth's surface on a spheroid (ellipsoid). One use for a geodesic line is when you want 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 —A loxodrome is not the shortest distance between two points but instead defines the line of constant 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.
  • PRESERVE_SHAPE —This type calculates the area or length of the geometry on the surface of the earth ellipsoid, for geometry defined in a projected or geographic coordinate system. This option preserves the shape of the geometry in its coordinate system.

(默认值为 GEODESIC)

String
units

The units in which the area will be calculated.

Areal unit of measure keywords: ACRES | ARES | HECTARES | SQUARECENTIMETERS | SQUAREDECIMETERS | SQUAREINCHES | SQUAREFEET | SQUAREKILOMETERS | SQUAREMETERS | SQUAREMILES | SQUAREMILLIMETERS | SQUAREYARDS

String

返回值

数据类型说明
Double

要素的面积。

默认情况下,在投影坐标系中,将采用坐标系的单位返回面积,在地理坐标系中,将以平方米为单位返回面积。

getLength ({measurement_type}, {units})
参数说明数据类型
measurement_type

PLANAR measurements reflect the projection of geographic data onto the 2D surface (in other words, they will not take into account the curvature of the earth). GEODESIC, GREAT_ELLIPTIC, LOXODROME, and PRESERVE_SHAPE measurement types may be chosen as an alternative, if desired.

  • GEODESIC —The shortest line between any two points on the earth's surface on a spheroid (ellipsoid). One use for a geodesic line is when you want 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 —A loxodrome is not the shortest distance between two points but instead defines the line of constant 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.
  • PRESERVE_SHAPE —This type calculates the area or length of the geometry on the surface of the earth ellipsoid, for geometry defined in a projected or geographic coordinate system. This option preserves the shape of the geometry in its coordinate system.

(默认值为 GEODESIC)

String
units

The units in which the length will be calculated.

Linear unit of measure keywords: CENTIMETERS | DECIMETERS | FEET | INCHES | KILOMETERS | METERS | MILES | MILLIMETERS | NAUTICALMILES | YARDS

String

返回值

数据类型说明
Double

要素的长度。

默认情况下,在投影坐标系中,将采用坐标系的单位返回长度,在地理坐标系中,将以米为单位返回长度。

getPart ({index})
参数说明数据类型
index

几何的索引位置。

Integer

返回值

数据类型说明
Array

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

intersect (other, dimension)
参数说明数据类型
other

The second geometry.

Object
dimension

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

  • 1 —A zero-dimensional geometry (point or multipoint).
  • 2 —A one-dimensional geometry (polyline).
  • 4 —A two-dimensional geometry (polygon).
Integer

返回值

数据类型说明
Object

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

measureOnLine (in_point, {as_percentage})
参数说明数据类型
in_point

A point (PointGeometry or Point) that is used to measure from the start point of the polyline.

PointGeometry
as_percentage

If False, the measure will be returned as a distance; if True, the measure will be returned as a percentage.

(默认值为 False)

Boolean

返回值

数据类型说明
Double

一个距离或百分比。

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

A second geometry.

Object

返回值

数据类型说明
Boolean

返回布尔值为 True 表示两个几何的交集具有与其中一个输入几何相同的尺寸。

pointFromAngleAndDistance (angle, distance, {method})
参数说明数据类型
angle

The angle in degrees to the returned point.

Double
distance

The distance in meters to the returned point.

Double
method

PLANAR measurements reflect the projection of geographic data onto the 2D surface (in other words, they will not take into account the curvature of the earth). GEODESIC, GREAT_ELLIPTIC, LOXODROME, and PRESERVE_SHAPE measurement types may be chosen as an alternative, if desired.

  • GEODESIC —The shortest line between any two points on the earth's surface on a spheroid (ellipsoid). One use for a geodesic line is when you want 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 —A loxodrome is not the shortest distance between two points but instead defines the line of constant 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.
  • PRESERVE_SHAPE —This type calculates the area or length of the geometry on the surface of the earth ellipsoid, for geometry defined in a projected or geographic coordinate system. This option preserves the shape of the geometry in its coordinate system.

(默认值为 GEODESIC)

String

返回值

数据类型说明
PointGeometry

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

positionAlongLine (value, {use_percentage})
参数说明数据类型
value

The distance along the line.

If the distance is less than zero, then the starting point of the line will be returned; if the distance is greater than the length of the line, then the end point of the line will be returned.

Double
use_percentage

The distance may be specified as a fixed unit of measure or a ratio of the length of the line.

If True, value is used as a percentage; if False, value is used as a distance. For percentages, the value should be expressed as a double from 0.0 (0%) to 1.0 (100%).

(默认值为 False)

Boolean

返回值

数据类型说明
PointGeometry

线上距线起点指定距离的点。

projectAs (spatial_reference, {transformation_name})
参数说明数据类型
spatial_reference

The new spatial reference. This can be a SpatialReference object or the coordinate system name.

SpatialReference
transformation_name

The geotransformation name.

String

返回值

数据类型说明
Object

经投影的几何。

queryPointAndDistance (in_point, {as_percentage})
参数说明数据类型
in_point

The input point (PointGeometry or Point).

PointGeometry
as_percentage

If False, the measure will be returned as a distance; if True, the measure will be returned as a percentage.

(默认值为 False)

Boolean

返回值

数据类型说明
tuple

返回包含以下信息的一个元组:

  • 用来表示折线上距 in_point 最近的点的 PointGeometry。
  • 线的起点与线上所返回的点之间的距离。
  • 线和 in_point 之间的最小距离。
  • 用来表示 in_point 是否位于线的右侧的布尔值。线的方向决定左右两侧。
segmentAlongLine (start_measure, end_measure, {use_percentage})
参数说明数据类型
start_measure

The starting distance from the beginning of the line.

Double
end_measure

The ending distance from the beginning of the line.

Double
use_percentage

The start and end measures may be specified as fixed units or as a ratio.

If True, start_measure and end_measure are used as a percentage; if False, start_measure and end_measure are used as a distance. For percentages, the measures should be expressed as a double from 0.0 (0 percent) to 1.0 (100 percent).

(默认值为 False)

Boolean

返回值

数据类型说明
PolyLine

两点之间的线段。

snapToLine (in_point)
参数说明数据类型
in_point

A point (PointGeometry or Point) to be snapped to the line.

PointGeometry

返回值

数据类型说明
PointGeometry

捕捉到的点。

symmetricDifference (other)
参数说明数据类型
other

A second geometry.

Object

返回值

数据类型说明
Object

生成的几何。

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

A second geometry.

Object

返回值

数据类型说明
Boolean

返回布尔值为 True,表示几何的边界相交。

union (other)
参数说明数据类型
other

A second geometry.

Object

返回值

数据类型说明
Object

生成的几何。

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

A second geometry.

Object

返回值

数据类型说明
Boolean

返回布尔值 True 表示该几何被包含在另一个几何之内。

代码实例

折线示例

从头开始创建折线要素类。

import arcpy

# A list of features and coordinate pairs
feature_info = [[[1, 2], [2, 4], [3, 7]],
                [[6, 8], [5, 7], [7, 2], [9, 5]]]

# A list that will hold each of the Polyline objects
features = []

for feature in feature_info:
    # Create a Polyline object based on the array of points
    # Append to the list of Polyline objects
    features.append(
        arcpy.Polyline(
            arcpy.Array([arcpy.Point(*coords) for coords in feature])))

# Persist a copy of the Polyline objects using CopyFeatures
arcpy.CopyFeatures_management(features, "c:/geometry/polylines.shp")

相关主题

  • Point
  • PointGeometry
  • Polygon
  • Multipoint
  • Geometry
  • Array
  • 读取几何
  • 写入几何
  • 将几何对象与地理处理工具配合使用
有关此主题的反馈?

ArcGIS for Desktop

  • 主页
  • 文档
  • 合约
  • 支持

ArcGIS 平台

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

关于 Esri

  • 关于我们
  • 招贤纳士
  • 内部人员博客
  • 用户大会
  • 开发者峰会
Esri
© Copyright 2016 Environmental Systems Research Institute, Inc. | 隐私政策 | 法律声明