tag:blogger.com,1999:blog-2420860529344694449.post607495924130520713..comments2017-07-12T06:37:45.362-07:00Comments on Lin.ear th.inking: Fast polygon merging in JTS using Cascaded UnionDr JTShttp://www.blogger.com/profile/02383381220154739793noreply@blogger.comBlogger12125tag:blogger.com,1999:blog-2420860529344694449.post-32150333288746133422010-05-19T10:25:23.572-07:002010-05-19T10:25:23.572-07:00Good to hear, Tommy - thanks.Good to hear, Tommy - thanks.Dr JTShttps://www.blogger.com/profile/02383381220154739793noreply@blogger.comtag:blogger.com,1999:blog-2420860529344694449.post-79494917924432581972010-05-15T11:20:44.763-07:002010-05-15T11:20:44.763-07:00this is great, this reduced my program from 25 min...this is great, this reduced my program from 25 minutes to 1 minute!tommy chhenghttps://www.blogger.com/profile/12825487725511077661noreply@blogger.comtag:blogger.com,1999:blog-2420860529344694449.post-83511975418761692562009-01-12T16:32:00.000-08:002009-01-12T16:32:00.000-08:00Yes, CascadedUnion is in JTS 1.9, and is invoked b...Yes, CascadedUnion is in JTS 1.9, and is invoked by the Geometry.union() method.<BR/><BR/>Best thing to do would be to post some samples of your problem on the JTS list.Dr JTShttps://www.blogger.com/profile/02383381220154739793noreply@blogger.comtag:blogger.com,1999:blog-2420860529344694449.post-2260330962466682952009-01-12T16:06:00.000-08:002009-01-12T16:06:00.000-08:00Has this "Cascaded Union" been rolled into JTS 1.9...Has this "Cascaded Union" been rolled into JTS 1.9? The union operation I am calling (multigeometryInstance.union()) appears to result in a simplified geometry. For example, I have loaded a bunch of multipolygons (county subdivisions from the US Census for the state of PA) added them all to a multigeometry and called union on the multigeometry. The resulting geometry's border appears to be smoother than it was when I rendered all the multiplogons individually.Timhttps://www.blogger.com/profile/15186557262963464422noreply@blogger.comtag:blogger.com,1999:blog-2420860529344694449.post-43542067671107084242008-05-15T17:00:00.000-07:002008-05-15T17:00:00.000-07:00Necho, I'm not entirely sure what you mean. If the...Necho, <BR/><BR/>I'm not entirely sure what you mean. If the input polygons are valid (according to JTS) then the Cascaded Union should complete successfully. If the polygons are not valid, then you have to clean them up - which all depends on how they are invalid.<BR/><BR/>For more assistance you should post a description of the problem and sample data to the JTS user list.Dr JTShttps://www.blogger.com/profile/02383381220154739793noreply@blogger.comtag:blogger.com,1999:blog-2420860529344694449.post-80978142192349072152008-05-14T17:55:00.000-07:002008-05-14T17:55:00.000-07:00Hi professor, in my problem the polygons also have...Hi professor, in my problem the polygons also have internal segments and points as degenerated holes. So, there are several cases of interaction between borders. If this problem is fixed by the framework, I would like to use it. How can I get it?nechohttps://www.blogger.com/profile/04981353191499298185noreply@blogger.comtag:blogger.com,1999:blog-2420860529344694449.post-17999666455947935132008-05-14T17:54:00.000-07:002008-05-14T17:54:00.000-07:00Hi professor, in my problem the polygons also have...Hi professor, in my problem the polygons also have internal segments and points as degenerated holes. So, there are several cases of interaction between borders. If this problem is fixed by the framework, I would like to use it. How can I get it?nechohttps://www.blogger.com/profile/04981353191499298185noreply@blogger.comtag:blogger.com,1999:blog-2420860529344694449.post-136391146221251662008-02-29T15:03:00.000-08:002008-02-29T15:03:00.000-08:00This comment has been removed by a blog administrator.博https://www.blogger.com/profile/15469803290087254615noreply@blogger.comtag:blogger.com,1999:blog-2420860529344694449.post-29845163960789804622007-12-21T22:46:00.000-08:002007-12-21T22:46:00.000-08:00Yes, this algorithm handles polygons with holes no...Yes, this algorithm handles polygons with holes no problem, since it uses the standard JTS union() method for actually merging pairs of polygons. JTS provides full support for polygons with holes.Dr JTShttps://www.blogger.com/profile/02383381220154739793noreply@blogger.comtag:blogger.com,1999:blog-2420860529344694449.post-16838545655429672332007-12-21T20:14:00.000-08:002007-12-21T20:14:00.000-08:00Hello, I'm working in polygons union considering t...Hello, I'm working in polygons union considering the including of holes in to them (a ring by example ...), but my problem doesn't have a real espacial order for indexing. Did you work with this type of polygons??nechohttps://www.blogger.com/profile/04981353191499298185noreply@blogger.comtag:blogger.com,1999:blog-2420860529344694449.post-65200463665402590712007-12-08T10:16:00.000-08:002007-12-08T10:16:00.000-08:00Yep, indexing is key to making union efficient. I...Yep, indexing is key to making union efficient. Iterated union (what you've implemented) can be *very* slow in some cases. Using an index can speed this up dramatically (by eliminating lots of segments which don't appear in the final result).Dr JTShttps://www.blogger.com/profile/02383381220154739793noreply@blogger.comtag:blogger.com,1999:blog-2420860529344694449.post-42283288840052153642007-12-07T14:57:00.000-08:002007-12-07T14:57:00.000-08:00I'm coming to this a little late - about a month a...I'm coming to this a little late - about a month after it was posted -- but I just recently discovered your blog. I was having robustness problems with buffer(0) in the upcoming release of My World GIS, and I happened upon a pretty similar solution. It didn't occur to me to use a spatial index, though; I just use a linked list and repeatedly pull the first two elements from the front of the list and put their union at the end of the list:<BR/><BR/>(unfortunately, the <code> tag is not allowed in comments so this may look a bit messy):<BR/><BR/>public Geometry computeUnion (Geometry geom) <BR/>{<BR/> if (geom instanceof GeometryCollection) <BR/> {<BR/> GeometryCollection collection = (GeometryCollection)geom;<BR/> LinkedList glist = new LinkedList();<BR/> for (int i = 0; i < collection.getNumGeometries(); i += 1) <BR/> {<BR/> glist.add(computeUnion(collection.getGeometryN(i)));<BR/> }<BR/> while (glist.size() > 1) <BR/> {<BR/> Geometry geom1 = (Geometry)glist.removeFirst();<BR/> Geometry geom2 = (Geometry)glist.removeFirst();<BR/> Geometry result = geom1.union(geom2);<BR/> if (result.getClass() == GeometryCollection.class) <BR/> {<BR/> glist.addLast(collapse((GeometryCollection)result));<BR/> } <BR/> else <BR/> {<BR/> glist.addLast(result);<BR/> }<BR/> }<BR/> return (Geometry)glist.getFirst();<BR/> } <BR/> else <BR/> {<BR/> return geom;<BR/> }<BR/>}<BR/><BR/>(the collapse method takes the collection and turns it into a MultiPolygon) <BR/><BR/>I'm really looking forward to JTS 1.9 now, as I'm sure using the spatial index makes the behavior of the union method more predictable.Erichttps://www.blogger.com/profile/01249367299847810865noreply@blogger.com