Shapely 1.8.5 中文文档

  1. 主页
  2. 文档
  3. Shapely 1.8.5 中文文档
  4. User Manual
  5. Geometric Objects(几何对象)
  6. General Attributes and Methods(通用属性和方法)

General Attributes and Methods(通用属性和方法)

object.area

Returns the area (float) of the object.

返回对象的面积。

object.bounds

Returns a (minx, miny, maxx, maxy) tuple (float values) that bounds the object.

返回一个表示对象边界的元祖(minx, miny, maxx, maxy),即最小外包矩形。

object.length

Returns the length (float) of the object.

返回对象的长度。

object.minimum_clearance

Returns the smallest distance by which a node could be moved to produce an invalid geometry.

返回一个节点被移动以产生一个无效的几何形状的最小距离。

This can be thought of as a measure of the robustness of a geometry, where larger values of minimum clearance indicate a more robust geometry. If no minimum clearance exists for a geometry, such as a point, this will return math.infinity.

这可以被认为是衡量一个几何体的稳健性的标准,较大的最小间隙值表明一个更稳健的几何体。如果一个几何体不存在最小间隙,例如一个点,这将返回math.infinity。

New in Shapely 1.7.1

Requires GEOS 3.6 or higher.

>>> from shapely.geometry import Polygon
>>> Polygon([[0, 0], [1, 0], [1, 1], [0, 1], [0, 0]]).minimum_clearance
1.0

object.geom_type

Returns a string specifying the Geometry Type of the object in accordance with [1].

返回一个字符串,根据OpenGIS的格式标准指定对象的几何类型。

>>> Point(0, 0).geom_type
'Point'

object.distance(other)

Returns the minimum distance (float) to the other geometric object.

返回到其他几何对象的最小距离(浮点)。

>>> Point(0,0).distance(Point(1,1))
1.4142135623730951

object.hausdorff_distance(other)

Returns the Hausdorff distance (float) to the other geometric object. The Hausdorff distance between two geometries is the furthest distance that a point on either geometry can be from the nearest point to it on the other geometry.

返回到另一个几何对象的Hausdorff距离(浮点数)。两个几何对象之间的Hausdorff距离是任何一个几何对象上的一个点与另一个几何对象上的最近点之间的最远距离。

New in Shapely 1.6.0

>>> point = Point(1, 1)
>>> line = LineString([(2, 0), (2, 4), (3, 4)])
>>> point.hausdorff_distance(line)
3.605551275463989
>>> point.distance(Point(3, 4))
3.605551275463989

object.representative_point()

Returns a cheaply computed point that is guaranteed to be within the geometric object.

返回一个在几何对象内的点。该点为标记点,在计算时依照计算量最小而定,至确保在几何对象内部,并不代表几何对象的质心。

>>> donut = Point(0, 0).buffer(2.0).difference(Point(0, 0).buffer(1.0))
>>> donut.centroid.wkt
'POINT (-0.0000000000000001 -0.0000000000000000)'
>>> donut.representative_point().wkt
'POINT (-1.5000000000000000 0.0000000000000000)'
标签 ,
这篇文章对您有用吗?

我们要如何帮助您?

欢迎留下您的宝贵建议

Please enter your comment!
Please enter your name here