In QGIS I have a polygon SHP layer. The layer contains rings. I am reshaping the polygon layer by cutting away large areas of the polygons. When cutting away a part of the polygon that contains a ring, what happens to the ring? Is it completely removed?
[GIS] delete rings when reshaping polygons
editingqgis
Related Solutions
Quoting the shapefile specification:
A polygon consists of one or more rings. A ring is a connected sequence of four or more points that form a closed, non-self-intersecting loop. A polygon may contain multiple outer rings. The order of vertices or orientation for a ring indicates which side of the ring is the interior of the polygon. The neighborhood to the right of an observer walking along the ring in vertex order is the neighborhood inside the polygon. Vertices of rings defining holes in polygons are in a counterclockwise direction. Vertices for a single, ringed polygon are, therefore, always in clockwise order. The rings of a polygon are referred to as its parts.
So, by definition, a polygon must have at least one exterior ring. Interior rings (aka "holes") can only exist within a parent exterior ring. If there are multiple exterior rings, they can touch each other at a single point, but they cannot share a boundary or overlap. Interior rings must be wholly contained within their parent rings (they cannot touch the exterior ring at all), and can only touch other interior rings at a single point (again, no shared segment or overlap). Interior rings are distinguished from exterior rings by vertex order (clockwise for exterior and counter-clockwise for interior, as per "right hand rule"). There is no upper limit to the number of exterior rings, or to the number of interior rings within any given exterior ring (though file size limitations would impose an upper limit if you work it backwards, four points per ring, sixteen bytes per point -- roughly 33.5 million rings).
This blog posts tells how to do it with SQL in PostGIS http://geospatial.commons.gc.cuny.edu/2013/11/04/filling-in-holes-with-postgis/
Spatialite has also ExteriorRing function http://www.gaia-gis.it/gaia-sins/spatialite-sql-latest.html so you do not need to have PostGIS installed. Is it necessary for you to do the job with python inside QGIS? The SQL looks like this:
UPDATE my_spatial_table t
SET geom = a.geom
FROM (
SELECT gid, ST_Collect(ST_MakePolygon(geom)) AS geom
FROM (
SELECT gid, ST_NRings(geom) AS nrings,
ST_ExteriorRing((ST_Dump(geom)).geom) AS geom
FROM my_spatial_table
WHERE ST_NRings(geom) > 1
) s
GROUP BY gid, nrings
HAVING nrings > COUNT(gid)
) a
WHERE t.gid = a.gid;
Best Answer
I don't think anything happen to the ring as the Reshape tool does not allow rings to be cut if more than one polygon is crossed. The documentation regarding reshaping features might be helpful in describing this in more detail. The following quote is taken from the link:
If you want to reshape rings then make sure you only draw a line covering the ring itself. There is also the Delete Ring tool if you want to completely remove them.