Shapely 1.8.5 中文文档

  1. 主页
  2. 文档
  3. Shapely 1.8.5 中文文档
  4. User Manual
  5. Other Operations(其他操作)
  6. Efficient Rectangle Clipping(高效的矩形剪裁)

Efficient Rectangle Clipping(高效的矩形剪裁)

The clip_by_rect() function in shapely.ops returns the portion of a geometry within a rectangle.

shapely.ops中的clip_by_rect()函数返回一个几何对象在矩形内的部分。

  • shapely.ops.clip_by_rect(geomxminyminxmaxymax)

The geometry is clipped in a fast but possibly dirty way. The output is not guaranteed to be valid. No exceptions will be raised for topological errors.

几何对象以一种快速但可能是粗糙的方式被剪掉。输出不保证是有效的。对于拓扑结构的错误,将不会产生异常。

New in version 1.7.

Requires GEOS 3.5.0 or higher

需要GEOS 3.5.0或更高版本

>>> from shapely.geometry import Polygon
>>> from shapely.ops import clip_by_rect
>>> polygon = Polygon(
       shell=[(0, 0), (0, 30), (30, 30), (30, 0), (0, 0)],
       holes=[[(10, 10), (20, 10), (20, 20), (10, 20), (10, 10)]],
    )
>>> clipped_polygon = clip_by_rect(polygon, 5, 5, 15, 15)
>>> print(clipped_polygon.wkt)
POLYGON ((5 5, 5 15, 10 15, 10 10, 15 10, 15 5, 5 5))
标签 ,
这篇文章对您有用吗?

我们要如何帮助您?

欢迎留下您的宝贵建议

Please enter your comment!
Please enter your name here