2

Through this question and answer I've learned about the nature of Multipolygon shapefile, which was defined as multiple exterior rings. In short, (1) it contains multiple exterior rings (polygons), and (2) its attribute table shows one record for these multiple features.

So my expectation was, by choosing Multipolygon in Create New Temporary Scratch Layer dialog I could produce such file, i.e. multi-geometry plus single record. enter image description here

Choosing "Multipolygon" and create polygons with "Add feature",

enter image description here

then saving the scratch layer as shapefile, however, produced a polygon shapefile with multiple records. The picture below shows a purple shapefile named "test", which was created by "Save As" from the Scratch Layer. (RHS: Attribute table). enter image description here What did I do wrong? As multipolygon I anticipated a single record attribute table, but I see 4 records. Or, is this a bug?

(Note) Before saving, the Scratch layer (cyan "New scratch layer") also had 4 features in its attribute table, without attribute column. enter image description here

3
  • You did not include the most important details about how you created the features. It seems likely that you created several single ring shapes, and the output accuracy reflects this. Please edit the question.
    – Vince
    Commented Jan 22, 2017 at 14:33
  • @Vince Hi, added the process how I created shapes, which was exactly what you had pointed out. But I do not know way to direct create "multiple exterior rings".
    – Kazuhito
    Commented Jan 22, 2017 at 14:44
  • @Vince By above comment, what method were you trying to suggest to create Multipolygon?
    – Kazuhito
    Commented Jan 22, 2017 at 15:00

2 Answers 2

4

The following workflow should lead to your expected result:

  • Create your scratch layer (or directly a new shp file)
  • Draw the first polygon of your new MultiPolygon object
  • Then select this polygon with the selection tool or via the attribute table
  • Activate the "Add Part" option from the "Advanced Digitizing Toolbar" (see the screenshot with the highlighted button) Note: If you don't see this toolbar, activate it by right-clicking on the empty space beside your toolbars and enable the "Advanced Digitizing Toolbar"

enter image description here

  • Draw the rest of your MultiPolygon object, save your edits and save it in a new shp file if necessary
5
  • It works, thanks! ... But it presents Big question for me. It is virtually Multipart object, and it works regardless I choose Polygon or Multipolygon.
    – Kazuhito
    Commented Jan 22, 2017 at 14:55
  • 1
    Just to restate my point; my question was how to create Multipolygon, not Multipart polygon. Thanks anyway.
    – Kazuhito
    Commented Jan 22, 2017 at 15:06
  • 1
    I'm not sure, what is the difference between a Multipart and Multipolygon in your understanding. The structure shown in your screenshots above is in my opinion a multipolygon, which means a set of several polygon in one object (like a group of islands). EDIT: ESRI seems to refer to multipolygon features in their documentation as multipart (polygon) features, see also desktop.arcgis.com/en/arcmap/latest/manage-data/… So this might be the reason for the confusion. Commented Jan 22, 2017 at 17:07
  • If the operation to create a Multipolygon is actually creating a Multipart object, it does not make sense, given the same is applicable to Polygon, too.
    – Kazuhito
    Commented Jan 22, 2017 at 21:42
  • +1 Thank you for the intuitive guidance to add parts to polygons. It was not my original question, but it turned out I should not have worried Polygon or Multipolygon, so you were right; your answer is valid for my overall task on multi-geometries. Thanks again!
    – Kazuhito
    Commented Jan 22, 2017 at 22:47
3

From a formal point of view, I think that the object you have created is a multipolygon because it's a set of distinct polygons which don't satisfy one of the rules that define valid polygons (I report it from a previous answer):

The interior of every Polygon is a connected point set

So, referring to your sample object as a whole, this is sufficient to state that we are not talking about polygons here (instead, a multipolygon may be not a connected space).

Choosing the Polygon or Multipolygon option in the Create New Temporary Scratch Layer dialog only depends on what you are going to do with the layer and QGIS obviously doesn't know that (so, I don't think this could be an issue).

I remark that the difference between the two geometry types is purely formal (since shapefiles don't make a distinction between these objects) and I'll try to explain it better with an example which is partially inspired to @tallistroan's answer.

Regardless of what you choose in the Create New Temporary Scratch Layer dialog, you may edit your layer until to get this shape: enter image description here

which should be a multipolygon for the reasons explained above. Despite your initial choice doesn't affect what you can subsequently do with your layer, you made a formal mistake if you selected the "Polygon" option in the dialog; if this is the case, you will manage a multipolygon which is formally a polygon because this simple test from the Python Console:

layer = iface.activeLayer()
if layer.isValid():
    print layer.wkbType()

gives 3 as output (3 is the identifier for WKBPolygon types, while 6 is for WKBMultiPolygon, as defined in the QGIS API Documentation).

Made this clear, you were probably looking for a multipart object, which is a valid option for both polygons and multipolygons and takes in account a common attribute value which is shared by one or more features for creating a unique feature.

In the following figure I will try to explain what I intend for multipart object in both cases (in the multipart geometries, same colors belong to the same feature):

enter image description here

9
  • Great job. I think I now understand that "choosing Polygon or Multipolygon does not make difference" part. But the last part of your figure "Starting from a Multipolygon" only becomes true if choosing Multipolygon really creates a singlepart Multipolygon. Did you try this on Create New Temporary Scratch Layer? Or this is hand drawing?
    – Kazuhito
    Commented Jan 22, 2017 at 21:59
  • I started from a multpolygon layer and I created the first ring using the method proposed by @tallistroan; then, I continued creating another feature inside the ring, and so on... Initially, I had three features with different attributes (image on the left); then I changed the attribute values in order to obtain the multipart geometry.
    – mgri
    Commented Jan 22, 2017 at 22:03
  • ... And the answer to your question is: "Yes, I started from a singlepart multipolygon" ;)
    – mgri
    Commented Jan 22, 2017 at 22:12
  • Thanks so much! If you do not mind, can you also check if the nodes of your internal ring, or "hole", can touch the segment of the primary ring? I mean, the third Multipolygon figure in your answer (or the second from right-hand-side), as it was where I was stuck. I received warning that my hole had to stay within the outlining polygon, that made impossible to create "internal ring touching outer ring" Multipolygon.
    – Kazuhito
    Commented Jan 22, 2017 at 22:12
  • My aim was to see if Multipolygon creates a Singlepart geometry (like the green one with 3 features, in your figure above) before going through the process to create Multipart geometry. Sorry, probably my intention was not clear in the above.
    – Kazuhito
    Commented Jan 22, 2017 at 22:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.