-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Construct PolygonArray
or MultiPolygonArray
from Exterior Coordinates
#132
Construct PolygonArray
or MultiPolygonArray
from Exterior Coordinates
#132
Conversation
PolygonArray
using NumpyPolygonArray
from an Array of Exterior Coordinates
Depending on any initial feedback from the developers here, I'd be willing to continue implementing this to support Polygons with holes, MultiPolygons, etc. While this PR focusses on Polygons specifically, I believe other geometries could benefit from this type of construction support. |
PolygonArray
from an Array of Exterior Coordinates PolygonArray
from an Array/List of Exterior Coordinates
PolygonArray
from an Array/List of Exterior Coordinates PolygonArray
or MultiPolygonArray
from Exterior Coordinates
PolygonArray
or MultiPolygonArray
from Exterior Coordinates PolygonArray
or MultiPolygonArray
from Exterior Coordinates
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic added seems simple enough not to add a lot of tests, but it would still be nice with one for both polygon and multi-polygon.
Maybe also some tests that handle edge cases like wrong input shape/size.
Thank you for the PR! 👍 |
Closes #122
Overview
PolygonArray.from_exterior_coords()
andMultiPolygonArray.from_exterior_coords()
class methods, which take-in an list/array of exterior coordinates equivalent to the following which are derived from Shapely Polygons/MultiPolygonsspatialpandas/spatialpandas/geometry/polygon.py
Lines 40 to 42 in dd941f2
spatialpandas/spatialpandas/geometry/multipolygon.py
Lines 40 to 48 in dd941f2
Usage
In UXarray, we use SpatialPandas paired with Datashader to visualize geoscience data that resides on unstructured grids as Polygons. Our unstructured grid is represented as a set of connectivity and coordinate arrays, which we would like to avoid needing to convert to Shapely, because we can derive the exterior of each Polygon quickly using the connectivity and coordinate information.
Performance Comparison
Initial benchmarks, comparing across
n_polygon
&n_vertices
All benchmarks are run on an NCAR Casper HPC Node, with 4 CPU Threads and 128gb of Memory
Test 1
(40,000,000 Closed Polygons with 7 total verticies)
Roughly a 16x speedup compared to using Shapely