Shapely 1.8.5 中文文档

  1. 主页
  2. 文档
  3. Shapely 1.8.5 中文文档
  4. User Manual
  5. Geometric Objects(几何对象)
  6. Coordinate sequences(坐标序列)

Coordinate sequences(坐标序列)

The list of coordinates that describe a geometry are represented as the CoordinateSequence object. These sequences should not be initialised directly, but can be accessed from an existing geometry as the Geometry.coords property.

CoordinateSequence对象用于描述一个几何要素的坐标序列。这些序列不应该被直接初始化,但可以通过Geometry.coords属性从一个现有的几何要素中获得。

>>> line = LineString([(0, 1), (2, 3), (4, 5)])
>>> line.coords
<shapely.coords.CoordinateSequence object at 0x00000276EED1C7F0>

Coordinate sequences can be indexed, sliced and iterated over as if they were a list of coordinate tuples.

坐标序列可以被索引、切分和迭代,就像它们是一个坐标元祖组成的列表一样。

>>> line.coords[0]
(0.0, 1.0)
>>> line.coords[1:]
[(2.0, 3.0), (4.0, 5.0)]
>>> for x, y in line.coords:
...     print("x={}, y={}".format(x, y))
...
x=0.0, y=1.0
x=2.0, y=3.0
x=4.0, y=5.0

Polygons have a coordinate sequence for their exterior and each of their interior rings.

多边形的外环和每个内环都有一个坐标序列。

>>> poly = Polygon([(0, 0), (0, 1), (1, 1), (0, 0)])
>>> poly.exterior.coords
<shapely.coords.CoordinateSequence object at 0x00000276EED1C048>

Multipart geometries do not have a coordinate sequence. Instead the coordinate sequences are stored on their component geometries.

复合几何元素没有坐标序列。坐标序列被存储在组成其的几何要素上。

>>> p = MultiPoint([(0, 0), (1, 1), (2, 2)])
>>> p[2].coords
<shapely.coords.CoordinateSequence object at 0x00000276EFB9B320>
标签 ,
这篇文章对您有用吗?

我们要如何帮助您?

欢迎留下您的宝贵建议

Please enter your comment!
Please enter your name here