[Gdal-dev] Intersection of two OGRLinearRing objects is NULL

Mateusz Loskot mateusz at loskot.net
Thu Nov 8 12:10:01 EST 2007

Dmitry Kan wrote:
> Hello list!
> I have two polygons. I know that their exterior rings intersect in two
> OGRPoint's. Despite that fact Intersection() on the ring objects return


I did short test:
I changed LINEARRING to LINESTRING because it's not possible to create
LINEARRING directly from WKT. Note, that LINEARRING should not be used
as standalone geometry but it's a variation of LINESTRING used to
support POLYGON geometries.
Next, I created two geometries and generated intersection.
The intersection operation succeeded and resulting geometry is of type
of 4, it is MultiPoint:

>>> import ogr
>>> a = open('a.txt').read()
>>> g1 = ogr.CreateGeometryFromWkt(a)
>>> g1.GetGeometryType()
>>> b = open('b.txt').read()
>>> g2 = ogr.CreateGeometryFromWkt(b)
>>> g2.GetGeometryType()
>>> ints = g1.Intersection(g2)
>>> print ints.GetGeometryType()

Files a.txt and b.txt consist of definition of your geometries.
I used GDAL from current SVN.

Mateusz Loskot

More information about the gdal-dev mailing list