RE: [gdal-dev] Topological Union?
I wound up using Spatialite (SQLite + WKB/GEOS support) instead of writing my own code. It was very fast and easy to setup. It would make a perfect teaching/learning tool for anyone who wants to learn about SQL and spatial operators. Craig -Original Message- From: Mateusz Loskot [mailto:[EMAIL PROTECTED] Sent: Friday, August 29, 2008 10:22 AM To: Craig Miller; Craig Miller Cc: 'Brent Fraser'; gdal-dev@lists.osgeo.org; 'Brent Fraser'; gdal-dev@lists.osgeo.org Subject: Re: [gdal-dev] Topological Union? Craig Miller wrote: > Thanks Brent. I'm looking for a C/C++ solution. I'll take a look at > the other polygon processing libraries as well as the level of effort > in porting JTS Cascaded Unions to Geos... that's a conversation for a > different mailing list though. Craig, I agree with Brent that performance is/may not be very impressive. In OGR, this is mostly caused by a need to convert OGRGeometry type to GEOS geometry type [1] - allocating & copying coordinates data is expansive. However, if you are developing your own solution in C++, you can avoid this by defining your geometry in terms of interface of geos::geom::Geometry or - following design pattern called adapter, you can provide a thin wrapper on your geometry type that will make it accessible to GEOS engine. This way you should get rid of major bottleneck of OGR<->GEOS interoperability. [1] http://trac.osgeo.org/gdal/browser/trunk/gdal/ogr/ogrgeometry.cpp#L2105 Best regards, -- Mateusz Loskot, http://mateusz.loskot.net Charter Member of OSGeo, http://osgeo.org ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Topological Union?
Craig Miller wrote: Thanks Brent. I'm looking for a C/C++ solution. I'll take a look at the other polygon processing libraries as well as the level of effort in porting JTS Cascaded Unions to Geos... that's a conversation for a different mailing list though. Craig, I agree with Brent that performance is/may not be very impressive. In OGR, this is mostly caused by a need to convert OGRGeometry type to GEOS geometry type [1] - allocating & copying coordinates data is expansive. However, if you are developing your own solution in C++, you can avoid this by defining your geometry in terms of interface of geos::geom::Geometry or - following design pattern called adapter, you can provide a thin wrapper on your geometry type that will make it accessible to GEOS engine. This way you should get rid of major bottleneck of OGR<->GEOS interoperability. [1] http://trac.osgeo.org/gdal/browser/trunk/gdal/ogr/ogrgeometry.cpp#L2105 Best regards, -- Mateusz Loskot, http://mateusz.loskot.net Charter Member of OSGeo, http://osgeo.org ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
RE: [gdal-dev] Topological Union?
Thanks Brent. I'm looking for a C/C++ solution. I'll take a look at the other polygon processing libraries as well as the level of effort in porting JTS Cascaded Unions to Geos... that's a conversation for a different mailing list though. Craig -Original Message- From: Brent Fraser [mailto:[EMAIL PROTECTED] Sent: Friday, August 29, 2008 7:53 AM To: Craig Miller Cc: gdal-dev@lists.osgeo.org Subject: Re: [gdal-dev] Topological Union? Craig, I've had limited success with the Union function in Geos (via GDAL). It's slow and fails on large polygon sets (some of my files have 10,000 polygons with some convoluted geometry), but if your sets are smaller, it may work. FYI, Geos is derived (ported?) from JTS; Martin Davis has a good explanation of union strategies at http://lin-ear-th-inking.blogspot.com/2007/11/fast-polygon-merging-in-jts-using.html. Currently, I'm considering using Geotools (http://geotools.codehaus.org/) as a framework to get at the JTS functionality. And there are other polygon processing libraries out there. There's a nice summary at http://www.complex-a5.ru/polyboolean/comp.html, but I haven't tried any of those yet. Good Luck! Brent Fraser Mateusz Loskot wrote: > Craig Miller wrote: >> Thanks Mateusz. That's exactly what I was thinking of doing if >> someone hasn't put it together already. > > Craig, > > BTW, you don't have to convert OGRGeometry (you play with it when > reading Shapefile using OGR) to geos::geom::Geometry. > > You can union OGRGeometry using OGRGeometry::Union() > or its C API equivalent OGR_G_Union > > These operations are based on GEOSUnion function. > > Best regards, No virus found in this incoming message. Checked by AVG - http://www.avg.com Version: 8.0.169 / Virus Database: 270.6.13/1641 - Release Date: 8/29/2008 7:07 AM ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Topological Union?
Craig, I've had limited success with the Union function in Geos (via GDAL). It's slow and fails on large polygon sets (some of my files have 10,000 polygons with some convoluted geometry), but if your sets are smaller, it may work. FYI, Geos is derived (ported?) from JTS; Martin Davis has a good explanation of union strategies at http://lin-ear-th-inking.blogspot.com/2007/11/fast-polygon-merging-in-jts-using.html. Currently, I'm considering using Geotools (http://geotools.codehaus.org/) as a framework to get at the JTS functionality. And there are other polygon processing libraries out there. There's a nice summary at http://www.complex-a5.ru/polyboolean/comp.html, but I haven't tried any of those yet. Good Luck! Brent Fraser Mateusz Loskot wrote: Craig Miller wrote: Thanks Mateusz. That's exactly what I was thinking of doing if someone hasn't put it together already. Craig, BTW, you don't have to convert OGRGeometry (you play with it when reading Shapefile using OGR) to geos::geom::Geometry. You can union OGRGeometry using OGRGeometry::Union() or its C API equivalent OGR_G_Union These operations are based on GEOSUnion function. Best regards, ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Topological Union?
Craig Miller wrote: Thanks Mateusz. That's exactly what I was thinking of doing if someone hasn't put it together already. Craig, BTW, you don't have to convert OGRGeometry (you play with it when reading Shapefile using OGR) to geos::geom::Geometry. You can union OGRGeometry using OGRGeometry::Union() or its C API equivalent OGR_G_Union These operations are based on GEOSUnion function. Best regards, -- Mateusz Loskot, http://mateusz.loskot.net Charter Member of OSGeo, http://osgeo.org ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Topological Union?
Craig Miller wrote: Are there any gdal/geos based utility out there that do a topological union between two sets of geometry (shape files)? AFAIR, GEOSUnion is a topological union // C API g3 = GEOSUnion(g1, g2); GEOS does not provide any Shapefile I/O features, but you can use OGR [1] to read Shapefile and access geomtry objects. [1] http://www.gdal.org/ogr/ Best regards, -- Mateusz Loskot, http://mateusz.loskot.net Charter Member of OSGeo, http://osgeo.org ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
[gdal-dev] Topological Union?
Are there any gdal/geos based utility out there that do a topological union between two sets of geometry (shape files)? A topological union results in existing geometry being split into multiple pieces and each new resulting polygon having all of the attributes of both source polygongs. For example in a Venn diagram, 2 overlapping circles would result in 3 polygons. A non-topological union results in all geometry being in the same set, but w/o any new areas being created where there is overlap. For example, in a Venn diagram, even though two circles are overlapping, the overlapped portion would not result in a new polygon; there would only be the two original circles as polygons. Thanks for the help, Craig ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev