block by davo 5131432

Export CartoDB GeoJSON to TopoJSON.

Full Screen

index.html

<!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="//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="//d3js.org/d3.v3.min.js"></script>
<script src="//d3js.org/d3.geo.projection.v0.min.js"></script>
<script src="//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>

world-data.csv