I have a TIN model where I remove some of the triangles (see fig. 1). Most of the triangles touch on one edge, some on one vertice. I would now like to generate a polygon shapefile containing the remaining triangles, dissolved into one polygon (of multiple rings, see fig. 2).
Fig 1. - TIN with some triangles removed. Vertices of touching triangles are exactly identical, no sliver polygons.
Fig. 2 - Note, that this is only one polygon with a single line in the attribute table
Pictures were made by using the QGIS "Vector-->Geoprocessing Tools-->Dissolve" tool. Is this possible with the ogr python bindings? Here's what I've tried so far:
from osgeo import ogr tri = ogr.Geometry(ogr.wkbLinearRing) tri.AddPoint(0,0) tri.AddPoint(0,1) tri.AddPoint(1,1) tri.CloseRings() poly = ogr.Geometry(ogr.wkbPolygon) poly.AddGeometry(tri) tri2 = ogr.Geometry(ogr.wkbLinearRing) tri2.AddPoint(1,1) tri2.AddPoint(0,1) tri2.AddPoint(0,4) poly2 = ogr.Geometry(ogr.wkbPolygon) poly2.AddGeometry(tri2) poly.Union(poly2) # returns None poly.Intersect(poly2) # returns False poly.Touches(poly2) # returns False (?) poly.Disjoint(poly2) # returns False
I'm missing something like
poly.Dissolve(), maybe used on a