Friday, 13 July 2018

Understanding difference between Polygon and Multipolygon for shapefiles in QGIS?



Creating Scratch layer gives me a choice between Polygon and Multipolygon, so I started wondering how should I make use of them.


New Temp Scratch Layer


Reading a new book "Mastering QGIS" (through this answer by Joseph to What does buffer mean in QGIS Voronoi dialog?), authors' comment was "ESRI shapefiles store geospatial data in multi- type geometry, so using multi- type geometry is a good practice if you plan on converting between formats."


How should I choose one of them (Polygon or Multipolygon) when I create a new polygon layer? (I had confused multi-polygon with multipart-polygon, so I used to choose Polygon.)


One recent situation I have come to choose Polygon/Multipolygon was Changing parallel line length to split polygon in QGIS? in which I draw a dummy polygon as a background layer. Working mainly on shapefiles it seemed I was supposed to choose Multipolygon, although I needed only one polygon. In this case what I needed was simple polygon geometry without any attribute (Not sure this example make any distinction.)



Answer



From a more formal point of view, I report the definition for both a polygon and a multipolygon (the following text and images come from this document of the OGC® Standards, all credits to the cited source).




Polygon


A Polygon is a planar Surface defined by 1 exterior boundary and 0 or more interior boundaries. Each interior boundary defines a hole in the Polygon.



The exterior boundary LinearRing defines the “top” of the surface which is the side of the surface from which the exterior boundary appears to traverse the boundary in a counter clockwise direction. The interior LinearRings will have the opposite orientation, and appear as clockwise when viewed from the "top".


The assertions for Polygons (the rules that define valid Polygons) are as follows:



  1. Polygons are topologically closed;

  2. The boundary of a Polygon consists of a set of LinearRings that make up its exterior and interior boundaries;

  3. No two Rings in the boundary cross and the Rings in the boundary of a Polygon may intersect at a Point but only as a tangent;

  4. A Polygon may not have cut lines, spikes or punctures;

  5. The interior of every Polygon is a connected point set;

  6. The exterior of a Polygon with 1 or more holes is not connected. Each hole defines a connected component of the exterior.



Below some examples of Polygons:


enter image description here




Multipolygon


A MultiPolygon is a MultiSurface whose elements are Polygons.


The assertions for MultiPolygons are as follows:



  1. The interiors of 2 Polygons that are elements of a MultiPolygon may not intersect;

  2. The boundaries of any 2 Polygons that are elements of a MultiPolygon may not “cross” and may touch at only a finite number of Points;

  3. A MultiPolygon is defined as topologically closed;


  4. A MultiPolygon may not have cut lines, spikes or punctures, a MultiPolygon is a regular closed Point set;

  5. The interior of a MultiPolygon with more than 1 Polygon is not connected; the number of connected components of the interior of a MultiPolygon is equal to the number of Polygons in the MultiPolygon


The boundary of a MultiPolygon is a set of closed Curves (LineStrings) corresponding to the boundaries of its element Polygons. Each Curve in the boundary of the MultiPolygon is in the boundary of exactly 1 element Polygon, and every Curve in the boundary of an element Polygon is in the boundary of the MultiPolygon.


Below some examples of MultiPolygons:


enter image description here


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...