block by jczaplew 9202878

Fun with PostGIS

Full Screen

Fun with PostGIS, or, how Kanye sees the world.

index.html

<!DOCTYPE html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
  <style>
  .latitude {
    stroke-width:1.5px;
    stroke:#777;
    fill:none;
  }
  </style>
</head>
<body>
  <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.v1.min.js"></script>
  <script type="text/javascript">

  var width = 960,
      height = 500;

  var projection = d3.geo.hammer()
       .precision(0.3)
       .scale(170);

  var path = d3.geo.path()
      .projection(projection);

  var svg = d3.select("body").append("svg")
      .attr("width", width)
      .attr("height", height)
      .append("g");
      
  d3.json("data.topojson", function(error, lines) {
    svg.selectAll(".latitude")
      .data(topojson.feature(lines, lines.objects.data).features)
      .enter().append("path")
      .attr("class", "latitude")
      .attr("d", path);
  });
</script>
</body>
</html>