Closed philipc2 closed 1 year ago
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.
Thank you for the PR! :+1:
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/MultiPolygonshttps://github.com/holoviz/spatialpandas/blob/dd941f2f5f6994c6f09996e9b8af315e16d00051/spatialpandas/geometry/polygon.py#L40-L42
https://github.com/holoviz/spatialpandas/blob/dd941f2f5f6994c6f09996e9b8af315e16d00051/spatialpandas/geometry/multipolygon.py#L40-L48
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