Slow convex hull computation for very fragmented rasters
See original GitHub issueRasters with lots of small holes are currently taking up to 20 minutes to ingest (10980 x 10980), with most of the time spent computing the convex hull of the footprint.
Possible remedies:
- Pre-filter raster data with
raster.features.sieve
to remove small-scale variability. This works well (cuts computation time to 30s), but what should the sieve size be? - Replace
shapely.ops.unary_union
withshapely.geometry.MultiPolygon
, since we don’t need to compute a real union to get the convex hull of the dataset (cuts computation time to 3min). - Use the chunked version of
compute_metadata
, which is considerably faster while computing the convex hull (cuts computation time to 1min). - Find a cheaper way to compute the convex hull of the raster, e.g. via
scipy.spatial.ConvexHull
. There should be no reason to polygonize the entire raster in order to get the convex hull. However, I would prefer to avoid introducing SciPy as a dependency if we can.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6
Top Results From Across the Web
Convex hull algorithms - Wikipedia
Computing the convex hull means that a non-ambiguous and efficient representation of the required convex shape is constructed. The complexity of the ...
Read more >Calculate volume of space defined by multiple overlapping 3D ...
If you are trying to calculate a local convex hull (which appears to operate in 2 dimensions), can you not project the extents...
Read more >GIS 05 Spatial Interpolation 4 Convex Hulls, TINs ... - YouTube
GIS 05 Spatial Interpolation 4 Convex Hulls, TINs, Raster Resampling, and Image Pyramids. 124 views 5 years ago GEOG 459/559: Geographic ...
Read more >CSE 521 Algorithms Geometric Algorithms Convex Hull in 2 ...
CSE 521 - Computational Geometry - Spring 2003. 2. Geometric Algorithms ... The convex hull is a polygon whose vertices ... Slow Convex...
Read more >Convex Hulls: Explained - Medium
This blog discusses some intuition and will give you a understanding of some of the interesting and good algorithms to compute a convex...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
By definition, only the first and last element of each row and column can contribute to the convex hull of an image. So by prefiltering the mask that is polygonized to these elements, the computational complexity is down from
O(n^2)
toO(2n)
. I got a working prototype, which cuts computation time to about 6s, at the expense of slightly higher memory consumption. That should be good enough for now.💯 💯