Boundary Methodology

For those looking to replicate or create workflows of their own, the following serves as a high-level overview of the steps carried out during spatial data processing to create the digital boundary file that can be clipped to any admin 0 layer. Source code used to perform transformations are available on GitHub. The primary tools used in this pipeline include QGIS (through JSON batch files), GDAL (command line), and Pandas (table transformations).

Input boundaries 1

Fig 1. The data processing pipeline takes the most detailed admin level available as the input.

Input boundaries 2

Fig 2. From this input, the boundaries between admin regions are extended outwards using voronoi polygons.

Input boundaries 3

Fig 3. The original input is dissolved with the resulting voronoi polygons to create a borderless digital boundary file.

Input boundaries 4

Fig 4. This new layer can be clipped with any other admin 0 layer.

Detailed Steps

  1. Extract the edges of the boundary file as a line, while retaining information about which part of the line corresponds to which admin area. From this input, we want to extend these edges outwards in an intelligent way that will fill in space far beyond the original boundaries.
    1. Start with the most detailed admin level available from the original source, with all attributes stripped except for codes used for joining.
    2. Dissolve to a single admin 0 polygon.
    3. Convert both the most detailed admin level and the dissolved admin 0 layer from polygons to lines.
    4. Intersect line layers together, retaining information about which line segment originated from which detailed admin level.
  2. Extract points along the lines to be used in generating voronoi polygons. Due to how voronoi polygons are generated, input points cannot be overlapping, so the ends of lines need to be trimmed an extremely small amount to allow a gap in between them. For this project, very small is defined as 0.000001 degrees (approx. 10cm)
    1. Apply a very small buffer to each line segment without dissolving results.
    2. Convert the buffers into lines.
    3. Intersect the buffer lines with the line segments used at the beginning of this part. Use a line intersection tool to create points where these two layers meet. This will result in points located a very small distance from the ends of each line.
    4. Using these points placed almost at the end of every line segment, generate a buffer of 0.000002 degrees. This is to ensure that points next to each other will have their buffers fully overlapping. Dissolve results.
    5. With these small buffers covering the ends of every line segment, use the difference tool to very slightly trim each line segment, so their ends no longer touch.
  3. In addition to creating points where boundaries meet along the edge, more points are required to generate a proper voronoi. Since voronoi complexity increases exponentially, adding points every few meters along a boundary would take days or weeks to process, especially for those with details coastlines (Chile, Indonesia, Philippines, etc). A better alternative is to use vertices only, although here line centroids are used instead, since using vertices sometimes introduce errors in the generated results.
    1. The input line segments were exploded so that every strait part along them became its own feature.
    2. Points are generated by taking the centre of each exploded line part.
    3. Points generated in step 2.3 are combined with the steps above to create a single layer.
  4. From these points spaced along the line, voronoi polygons intelligently extend outwards and allocate available space associated with the attributes of the edge point closest to it.
    1. Generate voronoi polygons from the input points, filling an area double the size of the original bounding box of the input.
    2. Dissolve polygons that originate from the same admin polygon.
    3. Merge this dissolved layer with the original admin layer through a union.
    4. In the attribute table, in places where the original admin and the voronoi polygons intersect, ignore the voronoi attributes and use only the original. In places where there is only voronoi polygons, use those values. Merge polygons together that share the same attribute values.
    5. Apply topology cleaning to ensure the integrity of the final result.
    6. Create higher admin levels by dissolving based on attributes.
    7. Clip all layers to desired global admin 0 layer.