Last active
August 4, 2020 08:58
-
-
Save njanakiev/47a144d3d11d249a1d347af37e9b7317 to your computer and use it in GitHub Desktop.
Voronoi Diagram of the World with Capitals as Centroids
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE ne_voronoi AS ( | |
WITH ne_voronoi_polygons AS ( | |
SELECT (ST_Dump(ST_VoronoiPolygons(ST_collect(geom)))).geom AS geom | |
FROM ne_110m_populated_places | |
WHERE featurecla = 'Admin-0 capital' | |
) | |
SELECT ST_Intersection(a.geom, b.geom) AS geom | |
FROM ( | |
SELECT ST_Union(wkb_geometry) AS geom | |
FROM ne_110m_admin_0_countries | |
) a | |
CROSS JOIN ne_voronoi_polygons b | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment