从多边形中找到最大面积矩形。

maxrect的Python项目详细描述


找到给定多边形的最大内接轴对齐矩形。 找到多个多边形的交集。

https://pl-amit.s3.amazonaws.com/demo/maxrect/maximal-rectangle.png

安装

pip install git+https://${GITHUB_TOKEN}@github.com/planetlabs/maxrect.git

cli

# For a given GeoJSON file
$ max-rect [path/to/file]# Piping
$ cat path/to/file.geojson | max-rect

# For a quick visualization
$ cat path/to/file.geojson | max-rect | geojsonio

# For comparison between the original polygon and the inscribed rectangle
$ cat path/to/file.geojson | max-rect --compare | geojsonio

# Find the intersection of two geojson files
poly-intersect path/to/file1.geojson path/to/file2.geojson | geojsonio

# Find the largest inscribed rectangle that sits within multiple shapes
poly-intersect path/to/file1.geojson path/to/file2.geojson | max-rect | geojsonio

# Find the intersection of two geojson files
poly-intersect path/to/file1.geojson path/to/file2.geojson | geojsonio

# Find the largest inscribed rectangle that sits within multiple shapes
poly-intersect path/to/file1.geojson path/to/file2.geojson | max-rect | geojsonio

Python

frommaxrectimportget_intersection,get_maximal_rectangle,rect2poly# For a given convex polygoncoordinates1=[[x0,y0],[x1,y1],...[xn,yn]]coordinates2=[[x0,y0],[x1,y1],...[xn,yn]]# find the intersection of the polygons_,coordinates=get_intersection([coordinates1,coordinates2])# get the maximally inscribed rectanglell,ur=get_maximal_rectangle(coordinates)# casting the rectangle to a GeoJSON-friendly closed polygonrect2poly(ll,ur)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何显示因用户而异的SQLite存储数据?   转换java。sql。将映射传递给Jackon的valueToTree方法时StringNode的时间戳   从java中的列表json获取值   unicode Java字符存储在什么编码中?   java如何让Spring数据存储库中的默认方法命中缓存?   java使用readClassDescriptor()和resolveClass()来允许序列化版本控制   数组通过另一个矩阵的一部分填充矩阵   如果包含使用正则表达式的字符串,则替换父XML标记的java   java清除SharedReference中的单个变量   java将变量值从一个jsp页面传输到另一个jsp页面   java JDBC+SQLite:DriveManager不加载所需的驱动程序   相同源代码的java Kotlin构建生成不同的二进制文件   Java中的元组枚举