How are the coordinates for a multipolygon (i.e. polygon with a hole in it) arranged?

Do shapefiles and geoJSON files always save the coordinates for the outer ring first?

I'm asking because I have a set of multipolygons with holes and I'm looking to convert them to standard polygons by removing the coordinates of the holes.

If the outer ring of the polygon is always saved as the first set of coordinates, then I know I can easily select those.

  • Hole does not change a polygon into a multipolygon in any other context than OpenStreetMap. Polygons can have holes. Multipolygons contain one or more polygons. Multipolygon with one outer ring can be modelled also as a polygon but if a feature has many outer rings then it must be expressed as a multipolygon. So do you have also real multipolygons in your data? – user30184 Aug 2 '18 at 21:18
  • Ok, so a polygon can contain a hole. So then a multipolygon is two or more polygons that are not connected but still considered the same object? – csft306 Aug 2 '18 at 21:24
  • Yes, like Canary Islands. But multipolygon with just one polygon member is valid as well. – user30184 Aug 2 '18 at 21:33

I recommend to read the specifications. GeoJSON https://tools.ietf.org/html/rfc7946

For type "Polygon", the "coordinates" member MUST be an array of linear ring coordinate arrays.

o For Polygons with more than one of these rings, the first MUST be the exterior ring, and any others MUST be interior rings. The exterior ring bounds the surface, and the interior rings (if present) bound holes within the surface.

3.1.7. MultiPolygon

For type "MultiPolygon", the "coordinates" member is an array of
Polygon coordinate arrays.

Shapefile https://www.esri.com/library/whitepapers/pdfs/shapefile.pdf. Notise that the specification defines also features with several exterior rings as polygons.

Polygon 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.

Later in the shapefile spec comes The order of rings in the points array is not significant.

Conclusion: From GeoJSON find the polygon members and from those select the first rings. From ESRI Shapefiles select rings which are ordered clockwise. But if you use some existing library for reading the shapefiles you must learn how it works.


A multipolygon is an array of polygons. So, holes belong to polygons, not multipolygons actually.

For example (see picture below):

P1 = [
       [ [2.0, 2.0], [3.0, 2.0], [3.0, 3.0], [2.0, 3.0], [2.0, 2.0] ]  # outer ring

P2 = [
       [ [0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0], [0.0, 0.0] ], # outer ring
       [ [0.2, 0.2], [0.8, 0.2], [0.8, 0.8], [0.2, 0.8], [0.2, 0.2] ]  # inner ring (Hole)
       [ [x, y], [x, y], ... ] # inner ring (if exists) (Hole2)
       [ [x, y], [x, y], ... ] # inner ring ...
       ...                     # inner ring ...

Multipolygon = [P1, P2]

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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