Skeletal demo for d3.geoVoronoi
by Philippe Rivière.
license: mit |
Skeletal demo for d3.geoVoronoi
by Philippe Rivière.
id | country | capital | lat | lon | |
---|---|---|---|---|---|
AFG | Afghanistan | Kabul | 34.516666666666666 | 69.18333333333334 | |
AGO | Angola | Luanda | -8.833333333333334 | 13.216666666666667 | |
ALB | Albania | Tirana | 41.31666666666667 | 19.816666666666666 | |
ARE | United Arab Emirates | Abu Dhabi | 24.466666666666665 | 54.36666666666667 | |
ARG | Argentina | Buenos Aires | -34.583333333333336 | -58.666666666666664 | |
ARM | Armenia | Yerevan | 40.166666666666664 | 44.5 | |
AUS | Australia | Canberra | -35.266666666666666 | 149.13333333333333 | |
AUT | Austria | Vienna | 48.2 | 16.366666666666667 | |
AZE | Azerbaijan | Baku | 40.38333333333333 | 49.86666666666667 | |
BDI | Burundi | Bujumbura | -3.3666666666666667 | 29.35 | |
BEL | Belgium | Brussels | 50.833333333333336 | 4.333333333333333 | |
BEN | Benin | Porto-Novo | 6.483333333333333 | 2.6166666666666667 | |
BFA | Burkina Faso | Ouagadougou | 12.366666666666667 | -1.5166666666666666 | |
BGD | Bangladesh | Dhaka | 23.716666666666665 | 90.4 | |
BGR | Bulgaria | Sofia | 42.68333333333333 | 23.316666666666666 | |
BIH | Bosnia and Herzegovina | Sarajevo | 43.86666666666667 | 18.416666666666668 | |
BLR | Belarus | Minsk | 53.9 | 27.566666666666666 | |
BLZ | Belize | Belmopan | 17.25 | -88.76666666666667 | |
BMU | Bermuda | Hamilton | 32.28333333333333 | -64.78333333333333 | |
BOL | Bolivia | La Paz | -16.5 | -68.15 | |
BRA | Brazil | Brasilia | -15.783333333333333 | -47.916666666666664 | |
BTN | Bhutan | Thimphu | 27.466666666666665 | 89.63333333333334 | |
BWA | Botswana | Gaborone | -24.633333333333333 | 25.9 | |
CAF | Central African Republic | Bangui | 4.366666666666666 | 18.583333333333332 | |
CAN | Canada | Ottawa | 45.416666666666664 | -75.7 | |
CHE | Switzerland | Bern | 46.916666666666664 | 7.466666666666667 | |
CHL | Chile | Santiago | -33.45 | -70.66666666666667 | |
CHN | China | Beijing | 39.916666666666664 | 116.38333333333334 | |
CMR | Cameroon | Yaounde | 3.8666666666666667 | 11.516666666666667 | |
COD | Democratic Republic of the Congo | Kinshasa | -4.316666666666666 | 15.3 | |
COL | Colombia | Bogota | 4.6 | -74.08333333333333 | |
CRI | Costa Rica | San Jose | 9.933333333333334 | -84.08333333333333 | |
CUB | Cuba | Havana | 23.116666666666667 | -82.35 | |
CYP | Cyprus | Nicosia | 35.166666666666664 | 33.36666666666667 | |
CZE | Czech Republic | Prague | 50.083333333333336 | 14.466666666666667 | |
DEU | Germany | Berlin | 52.516666666666666 | 13.4 | |
DJI | Djibouti | Djibouti | 11.583333333333334 | 43.15 | |
DNK | Denmark | Copenhagen | 55.666666666666664 | 12.583333333333334 | |
DOM | Dominican Republic | Santo Domingo | 18.466666666666665 | -69.9 | |
DZA | Algeria | Algiers | 36.75 | 3.05 | |
ECU | Ecuador | Quito | -0.21666666666666667 | -78.5 | |
EGY | Egypt | Cairo | 30.05 | 31.25 | |
ERI | Eritrea | Asmara | 15.333333333333334 | 38.93333333333333 | |
ESP | Spain | Madrid | 40.4 | -3.6833333333333336 | |
EST | Estonia | Tallinn | 59.43333333333333 | 24.716666666666665 | |
ETH | Ethiopia | Addis Ababa | 9.033333333333333 | 38.7 | |
FIN | Finland | Helsinki | 60.166666666666664 | 24.933333333333334 | |
FJI | Fiji | Suva | -18.133333333333333 | 178.41666666666666 | |
FLK | Falkland Islands | Stanley | -51.7 | -57.85 | |
FRA | France | Paris | 48.86666666666667 | 2.3333333333333335 | |
GAB | Gabon | Libreville | 0.38333333333333336 | 9.45 | |
GBR | United Kingdom | London | 51.5 | -0.08333333333333333 | |
GEO | Georgia | Tbilisi | 41.68333333333333 | 44.833333333333336 | |
GHA | Ghana | Accra | 5.55 | -0.21666666666666667 | |
GIN | Guinea | Conakry | 9.5 | -13.7 | |
GNQ | Equatorial Guinea | Malabo | 3.75 | 8.783333333333333 | |
GRC | Greece | Athens | 37.983333333333334 | 23.733333333333334 | |
GRL | Greenland | Nuuk | 64.18333333333334 | -51.75 | |
GTM | Guatemala | Guatemala City | 14.616666666666667 | -90.51666666666667 | |
GUY | Guyana | Georgetown | 6.8 | -58.15 | |
HND | Honduras | Tegucigalpa | 14.1 | -87.21666666666667 | |
HRV | Croatia | Zagreb | 45.8 | 16 | |
HTI | Haiti | Port-au-Prince | 18.533333333333335 | -72.33333333333333 | |
HUN | Hungary | Budapest | 47.5 | 19.083333333333332 | |
IDN | Indonesia | Jakarta | -6.166666666666667 | 106.81666666666666 | |
IND | India | New Delhi | 28.6 | 77.2 | |
IRL | Ireland | Dublin | 53.31666666666667 | -6.233333333333333 | |
IRN | Iran | Tehran | 35.7 | 51.416666666666664 | |
IRQ | Iraq | Baghdad | 33.333333333333336 | 44.4 | |
ISL | Iceland | Reykjavik | 64.15 | -21.95 | |
ISR | Israel | Jerusalem | 31.766666666666666 | 35.233333333333334 | |
ITA | Italy | Rome | 41.9 | 12.483333333333333 | |
JAM | Jamaica | Kingston | 18 | -76.8 | |
JOR | Jordan | Amman | 31.95 | 35.93333333333333 | |
JPN | Japan | Tokyo | 35.68333333333333 | 139.75 | |
KAZ | Kazakhstan | Astana | 51.166666666666664 | 71.41666666666667 | |
KEN | Kenya | Nairobi | -1.2833333333333332 | 36.81666666666667 | |
KGZ | Kyrgyzstan | Bishkek | 42.86666666666667 | 74.6 | |
KHM | Cambodia | Phnom Penh | 11.55 | 104.91666666666667 | |
KOS | Kosovo | Pristina | 42.666666666666664 | 21.166666666666668 | |
KWT | Kuwait | Kuwait City | 29.366666666666667 | 47.96666666666667 | |
LAO | Laos | Vientiane | 17.966666666666665 | 102.6 | |
LBN | Lebanon | Beirut | 33.86666666666667 | 35.5 | |
LBR | Liberia | Monrovia | 6.3 | -10.8 | |
LBY | Libya | Tripoli | 32.88333333333333 | 13.166666666666666 | |
LKA | Sri Lanka | Colombo | 6.916666666666667 | 79.83333333333333 | |
LSO | Lesotho | Maseru | -29.316666666666666 | 27.483333333333334 | |
LTU | Lithuania | Vilnius | 54.68333333333333 | 25.316666666666666 | |
LUX | Luxembourg | Luxembourg | 49.6 | 6.116666666666666 | |
LVA | Latvia | Riga | 56.95 | 24.1 | |
MAR | Morocco | Rabat | 34.016666666666666 | -6.816666666666666 | |
MDA | Moldova | Chisinau | 47 | 28.85 | |
MDG | Madagascar | Antananarivo | -18.916666666666668 | 47.516666666666666 | |
MEX | Mexico | Mexico City | 19.433333333333334 | -99.13333333333334 | |
MKD | Macedonia | Skopje | 42 | 21.433333333333334 | |
MLI | Mali | Bamako | 12.65 | -8 | |
MLT | Malta | Valletta | 35.88333333333333 | 14.5 | |
MMR | Myanmar | Rangoon | 16.8 | 96.15 | |
MNE | Montenegro | Podgorica | 42.43333333333333 | 19.266666666666666 | |
MNG | Mongolia | Ulaanbaatar | 47.916666666666664 | 106.91666666666667 | |
MOZ | Mozambique | Maputo | -25.95 | 32.583333333333336 | |
MRT | Mauritania | Nouakchott | 18.066666666666666 | -15.966666666666667 | |
MWI | Malawi | Lilongwe | -13.966666666666667 | 33.78333333333333 | |
MYS | Malaysia | Kuala Lumpur | 3.1666666666666665 | 101.7 | |
NAM | Namibia | Windhoek | -22.566666666666666 | 17.083333333333332 | |
NCL | New Caledonia | Noumea | -22.266666666666666 | 166.45 | |
NER | Niger | Niamey | 13.516666666666667 | 2.1166666666666667 | |
NGA | Nigeria | Abuja | 9.083333333333334 | 7.533333333333333 | |
NIC | Nicaragua | Managua | 12.133333333333333 | -86.25 | |
NLD | Netherlands | Amsterdam | 52.35 | 4.916666666666667 | |
NOR | Norway | Oslo | 59.916666666666664 | 10.75 | |
NPL | Nepal | Kathmandu | 27.716666666666665 | 85.31666666666666 | |
NZL | New Zealand | Wellington | -41.3 | 174.78333333333333 | |
OMN | Oman | Muscat | 23.616666666666667 | 58.583333333333336 | |
PAK | Pakistan | Islamabad | 33.68333333333333 | 73.05 | |
PAN | Panama | Panama City | 8.966666666666667 | -79.53333333333333 | |
PER | Peru | Lima | -12.05 | -77.05 | |
PHL | Philippines | Manila | 14.6 | 120.96666666666667 | |
PNG | Papua New Guinea | Port Moresby | -9.45 | 147.18333333333334 | |
POL | Poland | Warsaw | 52.25 | 21 | |
PRI | Puerto Rico | San Juan | 18.466666666666665 | -66.11666666666666 | |
PRT | Portugal | Lisbon | 38.71666666666667 | -9.133333333333333 | |
PRY | Paraguay | Asuncion | -25.266666666666666 | -57.666666666666664 | |
QAT | Qatar | Doha | 25.283333333333335 | 51.53333333333333 | |
ROU | Romania | Bucharest | 44.43333333333333 | 26.1 | |
RUS | Russia | Moscow | 55.75 | 37.6 | |
RWA | Rwanda | Kigali | -1.95 | 30.05 | |
ESH | Western Sahara | El-Aaiún | 27.153611 | -13.203333 | |
SAU | Saudi Arabia | Riyadh | 24.65 | 46.7 | |
SDN | Sudan | Khartoum | 15.6 | 32.53333333333333 | |
SDS | South Sudan | Juba | 4.85 | 31.616666666666667 | |
SEN | Senegal | Dakar | 14.733333333333333 | -17.633333333333333 | |
SLB | Solomon Islands | Honiara | -9.433333333333334 | 159.95 | |
SLE | Sierra Leone | Freetown | 8.483333333333333 | -13.233333333333333 | |
SLV | El Salvador | San Salvador | 13.7 | -89.2 | |
SOL | Somaliland | Hargeisa | 9.55 | 44.05 | |
SOM | Somalia | Mogadishu | 2.066666666666667 | 45.333333333333336 | |
SUR | Suriname | Paramaribo | 5.833333333333333 | -55.166666666666664 | |
SVK | Slovakia | Bratislava | 48.15 | 17.116666666666667 | |
SVN | Slovenia | Ljubljana | 46.05 | 14.516666666666667 | |
SWE | Sweden | Stockholm | 59.333333333333336 | 18.05 | |
SWZ | Swaziland | Mbabane | -26.316666666666666 | 31.133333333333333 | |
SYR | Syria | Damascus | 33.5 | 36.3 | |
TCD | Chad | N'Djamena | 12.1 | 15.033333333333333 | |
TGO | Togo | Lome | 6.116666666666666 | 1.2166666666666668 | |
THA | Thailand | Bangkok | 13.75 | 100.51666666666667 | |
TJK | Tajikistan | Dushanbe | 38.55 | 68.76666666666667 | |
TKM | Turkmenistan | Ashgabat | 37.95 | 58.38333333333333 | |
TTO | Trinidad and Tobago | Port of Spain | 10.65 | -61.516666666666666 | |
TUN | Tunisia | Tunis | 36.8 | 10.183333333333334 | |
TUR | Turkey | Ankara | 39.93333333333333 | 32.86666666666667 | |
TWN | Taiwan | Taipei | 25.033333333333335 | 121.51666666666667 | |
UGA | Uganda | Kampala | 0.31666666666666665 | 32.55 | |
UKR | Ukraine | Kyiv | 50.43333333333333 | 30.516666666666666 | |
URY | Uruguay | Montevideo | -34.85 | -56.166666666666664 | |
UZB | Uzbekistan | Tashkent | 41.31666666666667 | 69.25 | |
VEN | Venezuela | Caracas | 10.483333333333333 | -66.86666666666666 | |
VNM | Vietnam | Hanoi | 21.033333333333335 | 105.85 | |
VUT | Vanuatu | Port-Vila | -17.733333333333334 | 168.31666666666666 | |
PSE | Palestine | Jerusalem | 31.766666666666666 | 35.233333333333334 | |
YEM | Yemen | Sanaa | 15.35 | 44.2 | |
ZAF | South Africa | Pretoria | -25.7 | 28.216666666666665 | |
ZMB | Zambia | Lusaka | -15.416666666666666 | 28.283333333333335 | |
ZWE | Zimbabwe | Harare | -17.816666666666666 | 31.033333333333335 | |
CIV | Ivory Coast | Yamoussoukro | 6.816666666666666 | -5.266666666666667 | |
BHS | The Bahamas | Nassau | 25.083333333333332 | -77.35 | |
BRN | Brunei | Bandar Seri Begawan | 4.883333333333333 | 114.93333333333334 | |
COG | Republic of the Congo | Brazzaville | -4.25 | 15.283333333333333 | |
PRK | North Korea | Pyongyang | 39.016666666666666 | 125.75 | |
GMB | Gambia | Banjul | 13.45 | -16.566666666666666 | |
GNB | Guinea Bissau | Bissau | 11.85 | -15.583333333333334 | |
KOR | South Korea | Seoul | 37.55 | 126.98333333333333 | |
SRB | Republic of Serbia | Belgrade | 44.833333333333336 | 20.5 | |
TLS | Timor-Leste | Dili | -8.583333333333334 | 125.6 | |
TZA | United Republic of Tanzania | Dar es Salaam | -6.8 | 39.28333333333333 | |
USA | United States of America | Washington, DC | 38.88333333333333 | -77.03333333333333 |
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<style> | |
#sphere { | |
fill: #ccc; | |
stroke: #444; | |
stroke-width: 2; | |
} | |
.polygons { | |
stroke: #444; | |
} | |
.sites { | |
stroke: black; | |
fill: white; | |
} | |
</style> | |
<svg width="960" height="600"></svg> | |
<script src="https://d3js.org/d3.v5.min.js"></script> | |
<script src="https://unpkg.com/d3-delaunay@5"></script> | |
<script src="https://unpkg.com/d3-geo-voronoi@1.5"></script> | |
<script> | |
d3.csv('capitals.csv').then(function(points) { | |
// Extract the `lon` and `lat` columns from each row; add an epsilon | |
// to allow for capitals set in the exact same coordinates | |
var v = d3.geoVoronoi() | |
.x(function(row) { | |
return +row.lon + 1e-9 * Math.random(); | |
}) | |
.y(function(row) { | |
return +row.lat; | |
}) | |
(points); | |
var projection = d3.geoOrthographic(), | |
path = d3.geoPath().projection(projection); | |
var svg = d3.select("svg"); | |
svg.append('path') | |
.attr('id', 'sphere') | |
.datum({ type: "Sphere" }) | |
.attr('d', path); | |
svg.append('g') | |
.attr('class', 'polygons') | |
.selectAll('path') | |
.data(v.polygons().features) | |
.enter() | |
.append('path') | |
.attr('d', path) | |
.attr('fill', function(_,i) { return d3.schemeCategory10[i%10]; }); | |
var c = { | |
type: "MultiPoint", | |
coordinates: points | |
.map(function(d) { | |
return[ +d.lon, +d.lat ]; | |
}) | |
}; | |
console.log(c); | |
svg.append('path') | |
.attr('class', 'sites') | |
.datum(c) | |
.attr('d', path); | |
// gentle animation | |
d3.interval(function(elapsed) { | |
projection.rotate([ elapsed / 150, 0 ]); | |
svg.selectAll('path') | |
.attr('d', path); | |
}, 50); | |
}); // d3.csv | |
</script> |