从多边形中找到最大面积的矩形。
项目描述
找到给定多边形内嵌的最大面积、轴对齐的矩形。找到多个多边形的交集。
安装
pip install git+https://${GITHUB_TOKEN}@github.com/planetlabs/maxrect.git
命令行界面
# 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
from maxrect import get_intersection, get_maximal_rectangle, rect2poly
# For a given convex polygon
coordinates1 = [ [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 rectangle
ll, ur = get_maximal_rectangle(coordinates)
# casting the rectangle to a GeoJSON-friendly closed polygon
rect2poly(ll, ur)
项目详情
关闭
maxrect-0.0.1dev.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 3b3e989ac15ab58de30751310d0c00a327210344d8a37ab1c38b0e5836f5d5f8 |
|
MD5 | d69b123e30ddfcd27a5ea6fbdb7faaca |
|
BLAKE2b-256 | 906471dbc5029ee061065a7c47aa2ac3a0c6621ef49f0eda736fc524dbf01311 |