Skip to main content
80 votes
Accepted

Understanding difference between Polygon and Multipolygon for shapefiles in QGIS?

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 ...
mgri's user avatar
  • 16.2k
31 votes

Understanding difference between Polygon and Multipolygon for shapefiles in QGIS?

Shapefile polygons are constructed from one or more closed rings. If a shape has multiple rings, they can be exterior and interior (e.g., form a doughnut), or multiple exterior (e.g., island chain). ...
Vince's user avatar
  • 20.1k
24 votes
Accepted

Converting Polygon to MultiPolygon with Shapely?

You can wrap the polygon in a list and pass that as an argument to the MultiPolygon constructor. Demo: from shapely.geometry.multipolygon import MultiPolygon from shapely import wkt p = wkt.loads(u'...
jpmc26's user avatar
  • 1,709
13 votes

What is a multipoint shapefile?

Shapefiles support four fundamental data types: Point, Polyline, Polygon, and Multipoint. Points are simple {X,Y} features. Polylines are ordered sets of points, and Polygons are the areas ...
Vince's user avatar
  • 20.1k
12 votes
Accepted

Merging spatially separated polygons into one feature in QGIS

Check the corresponding geoalgorithm in the Processing Toolbox (Ctrl+Shift+T). For QGIS 3 : "Promote to multipart" For QGIS 2 : "Singleparts to multipart"
eclipsed_by_the_moon's user avatar
11 votes
Accepted

Changing MultiLineString direction using PyQGIS

I will focus on the geometry creation part, because the feature editing part is fully explained in many places, including the example inside the question. I will use some Python list comprehension, ...
Javier JC's user avatar
  • 892
10 votes
Accepted

Splitting multipart polygons to single part in R?

If you are using the sf classes then you cast it from MULTIPOLYGON to POLYGON. Example using data from spData package: ncsf = st_read(system.file("shapes/sids.shp", package = "spData")[1]) > dim(...
Spacedman's user avatar
  • 64.3k
9 votes

Applying different style to each sub-part of multi-part geometry using QGIS

Here is an example using QGIS 3.24.2-Tisler and data from a PostGIS (PG:14-3.2) database. First create some dummy data in a PostGIS database: -- DROP TABLE IF EXISTS public.measurement; CREATE TABLE ...
swiss_knight's user avatar
  • 10.4k
8 votes
Accepted

How to select multi-part polygons from a layer using PyQGIS

This is an easier alternative. layer = iface.activeLayer() layer.selectByExpression("num_geometries( $geometry ) > 1") That's it! After that, note that you could also know how many ...
Germán Carrillo's user avatar
8 votes
Accepted

Create dissolved buffer from multi-geometry (Union by shared attribute and spatial intersection)

Starting with some random points, in an attept to imitate those in the OP's image, where the first two spatially intersect, then the 2nd and 3rd have the same attribute id (2), with a couple of other ...
John Powell's user avatar
  • 13.7k
8 votes
Accepted

Dividing multipart polygon into many polygons using QGIS

Your approach is almost correct. Singleparts to multipart from vector menu is (from version 2.16) using same tools as in processing toolbox, and as other processing tools from toolbox takes only ...
Oto Kaláb's user avatar
  • 6,915
8 votes
Accepted

Turning a single MultiPolygon into many small polygons?

As OP figured out, the ST_Dump function from PostGIS is one way to explode multipart geometries to single ones: When the input geometry is a collection or multi it will return a record for each of ...
Andre Silva's user avatar
  • 10.3k
8 votes
Accepted

Getting area of part of MultiPolygon in QGIS

Using Field Calc and Expressions: expression used: array_foreach( generate_series(1, num_geometries($geometry)), round(area(geometry_n( $geometry,@element)),0))
pigreco's user avatar
  • 4,480
7 votes
Accepted

Determining if polygon shapefile is multipart or singlepart using ArcMap

For ArcGIS v. 10.1 and older I'd create new field of integer type and populate it using: !Shape!.partCount Note parser is set to Python. It is much faster with Add Geometry Attributes tool ...
FelixIP's user avatar
  • 23k
7 votes
Accepted

Using Dissolve and Multipart to Singlepart in QGIS?

Dissolve tool creates multipart features. With the field option, you are grouping the features that are going to be the geometry parts of a new feature, according to an attribute. That's fine. The ...
Gabriel De Luca's user avatar
7 votes
Accepted

Removing unknown shape from polygon shapefile in QGIS

Start editing Select the part Delete part Draw a polygon on top of the hole Select and merge
BERA's user avatar
  • 73.8k
7 votes

Getting area of part of MultiPolygon in QGIS

Using a script, you can get easily the areas. You need to check if it is multipart. parts method of QgsGeometry returns an iterator for parts layer = iface.activeLayer() for feat in layer....
Kadir Şahbaz's user avatar
7 votes

Getting "QgsPolygon: CurvePolygon EMPTY" when extracting the largest part of MultiPolygon using PyQGIS

I don't know why you get empty polygons, but you can use the following script: layer = iface.activeLayer() def get_largest_part(feat): geoms = feat.geometry().asGeometryCollection() geom = ...
Kadir Şahbaz's user avatar
6 votes
Accepted

How to place only one symbol on the centroid of a multipart polygon?

This feature is currently being evaluated to be integrated with QGIS 2.16 (and has good chances that it will be) will be part of QGIS with the 2.16 release and present on master builds from after Apr, ...
Matthias Kuhn's user avatar
6 votes

Merging spatially separated polygons into one feature in QGIS

If you wnat keep any other features in the layer (besides theese in your example) single, you can select required features and perform Merge Selected Features in editing. This option is in Advanced ...
Oto Kaláb's user avatar
  • 6,915
6 votes
Accepted

Inspecting individual Polygons of MultiPolygon in QGIS

Convert your MultiPolygon to single Polygons using the "Multipart to singleparts" from Menu Vector > Geometry Tools > Multipart to singleparts. Than use the Identify tool again. It ...
Babel's user avatar
  • 71.5k
6 votes
Accepted

Modifying specific vertices of MultiLineString using PyQGIS

About why it does not modify the actual vertices, here a quote from the docs --> its a read only copy: vertices(self) → QgsVertexIterator Returns a read-only, Java-style iterator for traversal of ...
MrXsquared's user avatar
  • 34.5k
6 votes
Accepted

Getting "QgsPolygon: CurvePolygon EMPTY" when extracting the largest part of MultiPolygon using PyQGIS

I've had success by returning a copy of the largest_part geometry within the function. Unfortunately, I can't really explain why that helps, but I can only assume there is some kind of issue with ...
CodeBard's user avatar
  • 3,551
6 votes
Accepted

Adding column that shows the number of parts of features

Use num_geometries( $geometry).
Babel's user avatar
  • 71.5k
6 votes

Removing partly overlapping lines within the same feature

I believe the issue is that the nodes of the different features are not coincidental. I replicated your issue and was able to solve it by running Snap Geometries to Layer (Snap to anchor nodes) before ...
Cushen's user avatar
  • 2,928
6 votes

Multipart to Singlepart in ogr2ogr

ogr2ogr has an -explodecollections flag. Different name – same result. ogr2ogr -explodecollections singlepart.gpkg multipart.gpkg
StefanBrand_EOX's user avatar
6 votes
Accepted

Processing performance: Singlepart vs Multipart Polygon

Clipping, intersection etc are performed two steps: Identify which features should be processed Process each feature found in the previous step. For step #1, the bounding box of each feature is ...
JGH's user avatar
  • 42.1k
6 votes
Accepted

TypeError when converting QgsMultiLineString to QgsGeometry using PyQGIS

QgsMultiLineString is a child class of QgsAbstractGeometry which can be used to create a QgsGeometry using the following constructor QgsGeometry(QgsAbstractGeometry geom) This means that you can ...
Kalak's user avatar
  • 3,847
5 votes
Accepted

Cut part of a shapefile

The reason why you cannot choose the embedded piece alone is that your layer has multipart polygons. Try Vector | Geometry Tools | Multipart to singleparts to break them apart. Or you may want to try ...
Kazuhito's user avatar
  • 30.9k
5 votes
Accepted

Float not iterable

Putting the comments together: import arcpy arcpy.env.workspace = "c:/esripress/python/data" fc = "Hawaii.shp" with arcpy.da.SearchCursor(fc, ["OID@","SHAPE@"]) as cursor: for row in cursor: ...
Michael Stimson's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible