Skip to content

Instantly share code, notes, and snippets.

@davo
Last active July 6, 2022 15:30
Show Gist options
  • Save davo/5131432 to your computer and use it in GitHub Desktop.
Save davo/5131432 to your computer and use it in GitHub Desktop.
Export CartoDB GeoJSON to TopoJSON.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- Le styles -->
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">
<style type="text/css">
body {
padding-top: 20px;
padding-bottom: 40px;
}
/* Custom container */
.container-narrow {
margin: 0 auto;
max-width: 960px;
}
.container-narrow > hr {
margin: 30px 0;
}
.country {
fill: #ccc;
stroke: #fff;
stroke-width: .5px;
stroke-linejoin: round;
}
.country-boundary {
fill: none;
stroke: #fff;
stroke-width: .5px;
stroke-linejoin: round;
}
</style>
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<div class="container-narrow">
<div class="row-fluid marketing">
<div class="span6" id="map">
</div>
</div>
</div> <!-- /container -->
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/d3.geo.projection.v0.min.js"></script>
<script src="http://d3js.org/topojson.v0.min.js"></script>
<script>
var width = 960,
height = 1160;
var svg = d3.select("#map").append("svg")
.attr("width", width)
.attr("height", height);
// Based the data transformation over the CartoDB
// $ topojson -o world-data-demo.json world-data.geojson --id-property iso3 -p name,pop2005
d3.json("world-data-demo.json", function(error, world) {
svg.append("path")
.datum(topojson.object(world, world.objects.countries))
.attr("d", d3.geo.path().projection(d3.geo.mercator()))
.attr("class", "country");
});
</script>
</body>
</html>
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
fips iso2 iso3 un name notes rwi_region rwi_region rwi_rank rwi_score rwi_institutional rwi_reporting rwi_safeguard rwi_enabling area pop2005 region subregion lon lat longitude latitude
SF ZA ZAF 710 South Africa Sub-Saharan Africa Sub-Saharan Africa 22 56 57 60 62 39 121447 47938663 2 18 23.121 -30.558 26.12849298 -28.507205
BC BW BWA 72 Botswana Sub-Saharan Africa Sub-Saharan Africa 30 47 55 28 53 69 56673 1835938 2 18 23.815 -22.182 24.50370655 -22.333345
GB GA GAB 266 Gabon Sub-Saharan Africa Sub-Saharan Africa 32 46 60 51 39 28 25767 1290693 2 17 11.797 -0.591 11.68262299 -0.820975
AO AO AGO 24 Angola Sub-Saharan Africa Sub-Saharan Africa 41 42 58 43 52 15 124670 16095214 2 17 17.544 -12.296 18.84260201 -11.9325
CG CD COD 180 Democratic Republic of the Congo Sub-Saharan Africa Sub-Saharan Africa 44 39 56 45 42 6 226705 58740547 2 17 23.654 -2.876 22.54053576 -4.036388397
CM CM CMR 120 Cameroon Sub-Saharan Africa Sub-Saharan Africa 47 34 63 33 25 17 46540 17795149 2 17 12.277 5.133 13.66583912 7.36792
EK GQ GNQ 226 Equatorial Guinea Sub-Saharan Africa Sub-Saharan Africa 56 13 27 14 4 4 2805 484098 2 17 10.488 1.607 10.44908329 1.67282
MO MA MAR 504 Morocco Middle East & North Africa Middle East & North Africa 24 53 80 47 63 32 44630 30494991 2 15 -5.758 32.706 -6.594759165 31.7915
EG EG EGY 818 Egypt Middle East & North Africa Middle East & North Africa 38 43 40 44 48 40 99545 72849793 2 15 29.872 26.494 29.52781265 26.822635
AG DZ DZA 12 Algeria Middle East & North Africa Middle East & North Africa 45 38 57 41 28 26 238174 32854159 2 15 2.632 28.163 0.628991924 28.03139
SU SD SDN 736 Sudan Sub-Saharan Africa Sub-Saharan Africa 50 31 80 17 35 8 237600 36899747 2 15 30.05 13.832 29.03242543 12.862805
LY LY LBY 434 Libya Sub-Saharan Africa Sub-Saharan Africa 55 19 11 29 15 10 175954 5918217 2 15 18.023 27.044 17.31801357 26.335105
ZA ZM ZMB 894 Zambia Sub-Saharan Africa Sub-Saharan Africa 17 61 71 62 72 37 74339 11478317 2 14 26.32 -14.614 25.40189571 -13.07585
TZ TZ TZA 834 Tanzania Sub-Saharan Africa Sub-Saharan Africa 27 50 44 48 68 42 88359 38477873 2 14 34.823 -6.27 34.31457313 -6.363525
MZ MZ MOZ 508 Mozambique Sub-Saharan Africa Sub-Saharan Africa 46 37 58 26 37 37 78409 20532675 2 14 37.923 -14.422 34.6654016 -18.662655
ZI ZW ZWE 716 Zimbabwe Sub-Saharan Africa Sub-Saharan Africa 51 31 48 23 56 6 38685 13119679 2 14 29.872 -19 29.31345625 -19.023315
GH GH GHA 288 Ghana Sub-Saharan Africa Sub-Saharan Africa 15 63 79 51 73 59 22754 2253501 2 11 -1.207 7.96 -0.97188135 7.934685
LI LR LBR 430 Liberia Sub-Saharan Africa Sub-Saharan Africa 16 62 83 62 71 31 9632 3441796 2 11 -9.657 6.682 -9.640549464 6.420595
GV GN GIN 324 Guinea Sub-Saharan Africa Sub-Saharan Africa 33 46 86 45 43 11 24572 9002656 2 11 -10.942 10.439 -9.604389027 9.938055
SL SL SLE 694 Sierra Leone Sub-Saharan Africa Sub-Saharan Africa 35 46 52 47 59 24 7162 5586403 2 11 -11.792 8.56 -11.89402953 8.462295
NI NG NGA 566 Nigeria Sub-Saharan Africa Sub-Saharan Africa 40 43 66 38 53 18 91077 141356083 2 11 8.105 9.594 7.846100339 9.01111
PP PG PNG 598 Papua New Guinea East Asia & Pacific East Asia & Pacific 39 43 59 34 50 38 45286 6069715 9 54 143.459 -5.949 144.4353529 -6.65382
AS AU AUS 36 Australia Western Australia OECD OECD 4 85 88 87 65 96 768230 20310208 9 53 136.189 -24.973 133.1235564 -25.00708
TD TT TTO 780 Trinidad and Tobago Latin America & Caribbean Latin America & Caribbean 10 74 64 83 86 52 513 1323722 19 29 -61.253 10.468 -61.24863405 10.42
US US USA 840 United States Gulf of Mexico OECD OECD 2 92 88 97 89 90 915896 299846449 19 21 -98.606 39.622 -99.61218582 37.237355
CA CA CAN 124 Canada Alberta OECD OECD 7 76 67 72 74 96 909351 32270507 19 21 -109.433 59.081 -110.7203678 56.81443
MX MX MEX 484 Mexico Latin America & Caribbean Latin America & Caribbean 6 77 84 83 81 53 190869 104266392 19 13 -102.535 23.951 -102.271892 23.634505
BR BR BRA 76 Brazil Latin America & Caribbean Latin America & Caribbean 5 80 82 78 96 66 845942 186830759 19 5 -53.089 -10.772 -49.69304742 -14.261725
CI CL CHL 152 Chile Latin America & Caribbean Latin America & Caribbean 8 75 77 74 65 87 74880 16295102 19 5 -69.433 -23.389 -71.56248524 -35.695835
CO CO COL 170 Colombia Latin America & Caribbean Latin America & Caribbean 9 74 75 73 91 58 103870 4494579 19 5 -73.076 3.9 -72.50291368 4.10837
PE PE PER 604 Peru Latin America & Caribbean Latin America & Caribbean 11 73 88 83 57 55 128000 27274266 19 5 -75.552 -9.326 -75.82823046 -9.2287
EC EC ECU 218 Ecuador Latin America & Caribbean Latin America & Caribbean 18 58 70 64 65 28 27684 13060993 19 5 -78.497 -1.385 -78.36241409 -1.785675
VE VE VEN 862 Venezuela Latin America & Caribbean Latin America & Caribbean 20 56 57 69 67 18 88205 26725573 19 5 -66.166 7.125 -65.40413507 6.4225
BL BO BOL 68 Bolivia Latin America & Caribbean Latin America & Caribbean 25 53 48 60 56 42 108438 9182015 19 5 -64.671 -16.715 -63.59768311 -16.285695
AJ AZ AZE 31 Azerbaijan Europe & Central Asia Eurasia & South Asia 28 48 57 54 51 24 8260 8352021 142 145 47.395 40.43 47.77542515 40.169735
IZ IQ IRQ 368 Iraq Middle East & North Africa Middle East & North Africa 29 47 57 52 63 9 43737 27995984 142 145 43.772 33.048 42.50818972 33.24446
BA BH BHR 48 Bahrain Middle East & North Africa Middle East & North Africa 31 47 38 40 59 58 71 724788 142 145 50.562 26.019 50.51466253 26.02208
YM YE YEM 887 Yemen Middle East & North Africa Middle East & North Africa 37 43 57 46 52 16 52797 21095679 142 145 48.355 15.807 49.37157138 15.79606
KU KW KWT 414 Kuwait Middle East & North Africa Middle East & North Africa 42 41 28 43 36 57 1782 2700 142 145 47.376 29.476 47.36353645 29.278885
SA SA SAU 682 Saudi Arabia Middle East & North Africa Middle East & North Africa 48 34 30 35 31 38 214969 2361236 142 145 44.585 24.023 45.07084156 23.885945
QA QA QAT 634 Qatar Middle East & North Africa Middle East & North Africa 54 26 15 14 20 66 1100 796186 142 145 51.191 25.316 51.22798832 25.335165
KZ KZ KAZ 398 Kazakhstan Europe & Central Asia Eurasia & South Asia 19 57 62 58 76 32 269970 15210609 142 143 67.301 48.16 66.47212059 47.970825
TX TM TKM 795 Turkmenistan Europe & Central Asia Eurasia & South Asia 57 5 13 4 0 3 46993 4833266 142 143 59.384 39.122 59.2464492 38.89985
TT TL TLS 626 Timor-Leste East Asia & Pacific East Asia & Pacific 13 68 77 82 70 28 1487 1067285 142 35 125.878 -8.822 125.5706078 -8.95673
ID ID IDN 360 Indonesia East Asia & Pacific East Asia & Pacific 14 66 76 66 75 46 181157 226063044 142 35 114.252 -0.976 113.240544 0.05125
RP PH PHL 608 Philippines East Asia & Pacific East Asia & Pacific 23 54 63 54 51 46 29817 84566163 142 35 122.466 11.118 125.161182 7.686248779
MY MY MYS 458 Malaysia East Asia & Pacific East Asia & Pacific 34 46 39 45 39 60 32855 25652985 142 35 102.195 4.201 102.0496328 3.99032
VM VN VNM 704 Vietnam East Asia & Pacific East Asia & Pacific 43 41 63 39 31 30 32549 85028643 142 35 105.314 21.491 107.7987124 15.96375
CB KH KHM 116 Cambodia East Asia & Pacific East Asia & Pacific 52 29 52 13 46 20 17652 13955507 142 35 104.564 12.714 105.0995633 12.56568
BM MM MMR 104 Myanmar East Asia & Pacific East Asia & Pacific 58 4 8 5 2 2 65755 47967266 142 35 96.041 21.718 95.99194968 19.26486
IN IN IND 356 India South Asia Eurasia & South Asia 12 70 60 72 83 61 297319 1134403141 142 34 78.5 21 80.24721817 21.786635
AF AF AFG 4 Afghanistan South Asia Eurasia & South Asia 49 33 63 29 38 8 65209 25067407 142 34 65.216 33.677 65.24004 33.939115
IR IR IRN 364 Iran (Islamic Republic of) Middle East & North Africa Middle East & North Africa 53 28 26 33 26 23 163620 69420607 142 34 54.301 32.565 53.95007645 32.489095
MG MN MNG 496 Mongolia East Asia & Pacific East Asia & Pacific 26 51 80 39 49 48 156650 2580704 142 30 102.876 46.056 105.3303557 46.862495
CH CN CHN 156 China East Asia & Pacific East Asia & Pacific 36 43 43 46 46 36 932743 1312978855 142 30 106.514 33.42 98.40326854 36.880135
NO NO NOR 578 Norway OECD OECD 1 98 100 97 98 98 30625 4638836 150 154 8.74 61.152 12.68715434 64.591665
UK GB GBR 826 United Kingdom OECD OECD 3 88 79 91 83 93 24193 60244834 150 154 -1.6 53 -1.928351582 54.30139
RS RU RUS 643 Russian Federation Europe & Central Asia Eurasia & South Asia 21 56 69 31 75 72 1638094 143953092 150 151 96.689 61.988 88.41604233 59.43595
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment