I am interested in finding all the vertices of all polygons which are not on the inside the most outer polygoin that can be formed in a shape file: Here is how I get all the vertices:
def __init__(self,shapeFilePath): driver = ogr.GetDriverByName('ESRI Shapefile') self.LandUses =  self.Codes =  #Store Categories self.NPolygons = 1 # number of polygons in layer self.dataSource = driver.Open(shapeFilePath, 0) self.layer = self.dataSource.GetLayer() self.NPolygons = self.layer.GetFeatureCount() self.Boundaries = [""]*self.NPolygons # store vertices of each polygon for polygon in range(self.NPolygons): area = self.layer.GetFeature(polygon) Name = area.GetField(0) Kategorie = area.GetField(1) self.LandUses.append(Name) self.Codes.append(Kategorie) geometry = area.GetGeometryRef() boundary_raw = str(geometry.GetBoundary()) #remove tail and head boundary = boundary_raw[12:-1] boundary = boundary.split(',') #print boundary #lenboundary = len(boundary) #convert each coordinate from string to float for x, point in enumerate(boundary): boundary[x] = point.split() boundingvertices=np.asarray(boundary, dtype=np.float64) self.Boundaries[polygon] = boundingvertices
But now I am stuck with a lot of vertices, and I don't know how to get the "mantle", here is a picture displaying what I need:
Before I go hacking my own solution, I'd like to know if the GDAL Gods have been kind and made something like this already.
Thanks a bunch! Oz
UPDATE: Found something call convex hull ... not sure, but testing...
UPDATE #2: Of course one could just join all the polygons ...