question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Slow convex hull computation for very fragmented rasters

See original GitHub issue

Rasters 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:

  1. 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?
  2. Replace shapely.ops.unary_union with shapely.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).
  3. Use the chunked version of compute_metadata, which is considerably faster while computing the convex hull (cuts computation time to 1min).
  4. 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:closed
  • Created 5 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
dionhaefnercommented, Sep 18, 2018

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) to O(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.

0reactions
j08luecommented, Sep 18, 2018

💯 💯

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found