I've searched, but can't find clear explanations how can I simply delete inner rings from existing polygons with python or extract outter rings and overwrite the geometry. Seems GDAL/OGR should be the simplest, but still I need some help...
Simple vision of mine would be:
dataSrc=driver.Open(shp)
layer=dataSrc.GetLayer()
for i in xrange(layer.GetFeatureCount()):
feature = layer.GetFeature(i)
geometry = feature.GetGeometryRef()
if geometry.GetArea()<200:
layer.DeleteFeature(i)
if geometry.GetGeometryCount()>1:
geometry=geometry.GetGeometryRef(0) #overwrite geom, getting the first ring outer
feature.SetGeometry(geometry)
layer.SetFeature(feature)
geometry.Destroy()
This doesn't loop through, it's just how I would like to see.
As I know the first ring or the first part of the geometry should be the outer ring, so I assumed I can just ask for it like that.Suppose that's not a problem.
So, probably the question is just about Updating Geometry. I open dataset withouth specific- Reading or Writing, so I assume it should let me write in it not just read. But if I do not want to have a new dataset, can I just update write like that or i should anywhays better create a new dataset?
Or maybe there is even more simple way to solve this with python?