Skip to content

Instantly share code, notes, and snippets.

@bycoffe
Created May 25, 2013 02:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bycoffe/5647635 to your computer and use it in GitHub Desktop.
Save bycoffe/5647635 to your computer and use it in GitHub Desktop.
$ ogr2ogr -f 'ESRI Shapefile' -t_srs 'EPSG:4326' drought.shp usdm130521.shp
$ topojson --cartesian --width=800 --height=800 -p -o drought.json drought=drought.shp
<!doctype html>
<meta charset="utf-8">
<html>
<head>
<style type="text/css">
path {
stroke-width: 1;
stroke: steelblue;
fill: #eee;
}
</style>
</head>
<body>
<div id="map"></div>
<script src="d3.v3.js"></script>
<script src="topojson.js"></script>
<script>
;(function() {
var width = 800,
height = 800;
d3.json("drought.json", function(err, data) {
var drought = window.drought = topojson.feature(data, data.objects.drought);
var map = d3.select('#map').append('svg')
.style('width', width)
.style('height', height);
var path = d3.geo.path().projection(null);
map.selectAll('path')
.data(drought.features)
.enter().append('path')
.attr('d', function(d, i) {
return path(d);
});
});
}());
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment