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

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 安卓工具栏   java接口VS API VS公共类   无法解析java。lang.ClassNotFoundException:在安卓 studio中找不到类“com.example.安卓.camera2basic.AutoFitTextureView”?   java等待线程正常完成   java在JTable中的prepareRenderer方法中编辑单元格数据是否可行?   java SessionNotCreatedException selenium webdriver   java Android Studio Gradle CreateProcess错误=2   java找不到适用于异常(int)的构造函数   javascript如何在不使用正则表达式的情况下检查输入是否为表情符号?   从JAVA运行ant时,JAVA_HOME变量不正确   long的java min值引发异常   java如何在这段代码中实现侦听器?   带有透明文本的java Android按钮   图像Java扫描仪问题(JFrame)   java模拟输入蒸汽似乎在Junit测试的第一次输入中就被吃掉了   压缩Java Deflater,现在和将来的结果相同(确定性)   java JTable getModel()。setValueAt从数组中删除第一个元素   java我有不同于编译器和计算器的价值   使用C#客户端调用基本身份验证java webservice   java相同类型的多个@Embedded字段在持久化后始终为空