All geometric objects with coordinate sequences (Point, LinearRing, LineString) provide the Numpy array interface and can thereby be converted or adapted to Numpy arrays.
所有具有坐标序列的几何对象(Point, LinearRing, LineString)都提供了Numpy数组接口,因此可以转换为Numpy数组。
>>> import numpy as np
>>> np.asarray(Point(0, 0).coords)
array([[0., 0.]])
>>> np.asarray(LineString([(0, 0), (1, 1)]).coords)
array([[0., 0.],
[1., 1.]])
The coordinates of the same types of geometric objects can be had as standard Python arrays of x and y values via the xy
attribute.
通过xy属性,同种类型的几何对象的坐标可以作为标准的Python的x、y值数组。
>>> Point(0, 0).xy
(array('d', [0.0]), array('d', [0.0]))
>>> LineString([(0, 0), (1, 1)]).xy
(array('d', [0.0, 1.0]), array('d', [0.0, 1.0]))