[gdal-dev] Intersection of polygon layers
u2546226 at anu.edu.au
Fri Nov 5 17:54:32 EDT 2010
If you're using Python, I'd recommend checking out the shapely package (
You can load your shapefile using ogr, and then import the geometry to
shapely where you can do the geometry predicate calculations:
>>> import ogr
>>> from shapely.wkb import loads
>>> source = ogr.Open("/tmp/world_borders.shp")
>>> borders = source.GetLayerByName("world_borders")
>>> feature = borders.GetNextFeature()
On 6 November 2010 06:08, yosuke kimura <yosukesabai at gmail.com> wrote:
> I am trying to calculate intersection of two polygon layers with
> polygons. I searched threads, found following thread, and what I got
> was that OGR/GEOS provide me to intersection of two features, but I
> have to write something in order to perform this operation for two
> layers with multiple features.
> Open source vector geoprocessing libraries?
> Intersect of two shapefiles
> My questions are:
> 1. Did I miss something? Is there development of library which takes
> two polygon layers to calculate intersection or other basic geometry
> operations that i find in OGR?
> 2. Assuming no to above, I got started writing code using python
> binding. Not having too much experience, I codes to go through all
> possible pair (complete bipartite), test with intersect, then run
> intersection if it returns true. I am wondering there is faster way
> to do this. I am thinking something like get envelope polygon of each
> feature first, and then test intersection of them and then perform
> intersect operation only when first test passes (i assume that it is
> easier to test intersect if there are only handful of vertices as
> oppose to hundreds of vertices in my case).
> Right now I am trying with layer of hundreds of thousands of polygons
> vs. thousands of polygon, and it seems to be taking 10s of hours to
> finish in my environment.
> Thank you,
> Yosuke Kimura
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the gdal-dev