<div dir="ltr">Hey Nyall!<div><br></div><div>About the union question, probably no good news there, unless your data has some very unlikely characteristics.  The GEOS Cascaded Union approach is remarkably efficient at unioning sets of overlapping polygons - which it sounds like you have.  The other alternative hack is to run buffer(0), but it is unlikely to be faster.  </div><div><br></div><div>IF the data was a true polygonal coverage (i.e. strictly non-overlapping) then there is a faster approach in GEOSCoverageUniion.  [1].  But if you are trying to find gaps then it's likely your data is not a true coverage.</div><div><br></div><div>As for actually finding gaps, the good news is that there likely is a more efficient and effective approach. But it's not implemented directly in GEOS, so will take some work to accomplish.  The algorithm is to reduce the input to a large set of line segments, and then discard all segments which occur more than once (irrespective of direction/vertex order).  What is left will be the outer boundaries and any internal gaps which occur.  You can then refine this by looking for segments which are nearly, but not exactly parallel.  It would probably be nice to provide this as GEOS functionality at some point...</div><div><br></div><div><br></div><div>[1] <a href="https://github.com/libgeos/geos/pull/158">https://github.com/libgeos/geos/pull/158</a></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Aug 26, 2019 at 7:50 PM Nyall Dawson <<a href="mailto:nyall.dawson@gmail.com" target="_blank">nyall.dawson@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hey GEOS community!<br>
<br>
I'm wondering if anyone has any sneaky/brilliant approaches on<br>
speeding up GEOS operations with complex input geometries. Right now<br>
I'm looking for a way to speed up a unary union operation with the<br>
order of 100 input polygons, each of which is quite complex. I'm<br>
currently throwing these all into GEOSUnaryUnion and relying on GEOS<br>
to internally do things the best way, but I suspect there IS some<br>
optimisations I could do to pre-process the geometries in order to<br>
speed up the actual union operation.<br>
<br>
Has anyone any tips here?<br>
<br>
The other operation I'd like to optimise somehow is detecting whether<br>
gaps exist between a set of features. Currently the code is unioning<br>
all the input goemetries, then differencing it against the area of<br>
interest and checking if the result is empty. I suspect there's a much<br>
smarter way of doing this which would avoid the expense of the<br>
differencing operation, so I'd love to hear if anyone has any<br>
optimised approaches for handling this...<br>
<br>
Nyall<br>
_______________________________________________<br>
geos-devel mailing list<br>
<a href="mailto:geos-devel@lists.osgeo.org" target="_blank">geos-devel@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/geos-devel" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/geos-devel</a></blockquote></div>