Skip to content

Instantly share code, notes, and snippets.

@poezn
Last active August 29, 2015 14:01
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 poezn/48da59e57bc09314c534 to your computer and use it in GitHub Desktop.
Save poezn/48da59e57bc09314c534 to your computer and use it in GitHub Desktop.
Aligning topojson?
Display the source blob
Display the rendered blob
Raw
{"type":"Topology","objects":{"agri":{"type":"GeometryCollection","bbox":[-122.32265710083642,32.6519607526292,-115.27161515597028,40.19146926332322],"geometries":[{"type":"Polygon","arcs":[[0]]},{"type":"Polygon","arcs":[[1]]},{"type":"Polygon","arcs":[[2]]},{"type":"Polygon","arcs":[[3]]},{"type":"Polygon","arcs":[[4]]}]}},"arcs":[[[9407,553],[140,149],[102,78],[150,-58],[99,-101],[-5,-56],[9,-81],[22,-85],[75,-251],[-9,-52],[-98,-58],[-235,-38],[-140,5],[-79,10],[-47,73],[-64,20],[-31,55],[2,92],[8,30],[86,33],[46,15],[-48,124],[-39,73],[-23,25],[142,127],[-63,-129]],[[4487,2304],[125,29],[96,6],[404,-3],[-194,-103],[-10,-35],[-38,-76],[-137,-96],[-70,-37],[-256,47],[-48,15],[128,253]],[[839,5758],[124,-214],[95,-179],[149,-100],[262,-228],[180,-199],[212,-165],[78,-93],[42,-82],[18,-39],[-13,-26],[-75,28],[-60,29],[-59,59],[-10,0],[-100,81],[-57,77],[-161,47],[-112,111],[-150,176],[-91,59],[-49,29],[-162,110],[-95,83],[0,33],[-68,104],[3,118],[-57,76],[-12,21],[168,84]],[[4269,3426],[85,-20],[1,52],[101,17],[30,46],[78,-31],[105,-29],[40,37],[50,54],[46,19],[104,11],[50,2],[92,-32],[-3,-32],[39,-72],[-2,-58],[-57,-41],[-52,-46],[-25,-59],[28,-77],[-6,-90],[-93,-25],[-60,24],[-65,51],[-82,17],[-19,0],[-139,-38],[-58,19],[-50,2],[-104,20],[-94,99],[-17,28],[64,20],[-29,53],[-12,42],[35,30],[19,7]],[[3617,3832],[-34,25],[-2,57],[110,14],[88,20],[87,3],[109,27],[53,53],[47,71],[16,58],[-61,48],[-7,32],[-84,16],[-102,7],[-116,41],[-151,11],[-77,59],[-141,61],[-189,102],[-172,83],[-70,122],[13,62],[-20,58],[-79,48],[-219,233],[-39,43],[-106,82],[-102,42],[-45,36],[-81,80],[-40,78],[-9,80],[-79,51],[-180,221],[-120,95],[-73,122],[-58,212],[-92,107],[-132,136],[-147,121],[12,48],[-35,58],[-70,-38],[-30,47],[-107,97],[-136,68],[-19,51],[26,58],[-48,151],[0,84],[6,64],[-34,53],[-90,34],[-68,94],[-48,-5],[-105,-33],[-2,88],[-19,62],[-2,77],[-24,47],[-91,191],[-13,58],[5,86],[12,30],[71,-39],[76,-24],[47,49],[-39,99],[-110,86],[-160,17],[-27,103],[-53,69],[-61,49],[-57,33],[-71,7],[-3,110],[21,143],[20,24],[7,45],[-17,89],[-34,52],[-15,81],[24,48],[26,105],[-62,39],[-8,58],[2,44],[-2,54],[5,50],[-6,77],[-7,57],[99,76],[36,47],[-2,71],[42,120],[25,41],[83,-32],[62,-128],[2,-84],[50,-67],[117,-100],[13,-64],[51,-69],[72,-72],[123,-62],[121,-88],[58,-73],[-52,-57],[0,-50],[19,-38],[63,-4],[19,-84],[43,-56],[54,-55],[74,-60],[81,-194],[53,-86],[17,-95],[-49,-62],[-7,-82],[-48,-78],[-37,-85],[-53,-104],[-83,-115],[23,-101],[93,-57],[-16,-71],[15,-51],[53,-3],[71,19],[69,10],[26,-51],[-8,-57],[11,-11],[82,-51],[144,-68],[82,-42],[43,-74],[140,-59],[99,-2],[-82,-53],[-41,-68],[1,-36],[69,-26],[36,-6],[63,-88],[74,-87],[16,-29],[50,-41],[54,-18],[75,-35],[66,-20],[20,-28],[32,-60],[41,-25],[38,-36],[39,2],[39,13],[50,25],[-1,-45],[15,-72],[-30,-47],[-55,-40],[-16,-79],[9,-6],[46,0],[0,-38],[-36,-27],[1,-39],[22,-40],[55,-2],[42,62],[32,25],[34,-12],[86,-1],[34,14],[74,-10],[-26,-24],[-1,-28],[9,-15],[30,-31],[103,-57],[77,-19],[0,-29],[-63,0],[-22,-27],[81,0],[60,3],[-17,-22],[-19,-7],[22,-24],[151,-78],[45,-26],[15,-26],[14,-36],[5,-49],[73,-8],[125,10],[44,-13],[-28,-23],[-10,-34],[-46,-20],[-36,-36],[-71,-12],[-30,-28],[-14,-29],[-2,-20],[7,-15],[38,-48],[40,-13],[55,-49],[52,-29],[63,-21],[40,6],[-4,35],[36,-1],[43,21],[27,42],[93,53],[128,-10],[93,0],[-23,-71],[1,-42],[63,-7],[26,24],[45,-23],[91,-69],[51,-70],[62,-44],[-1,-27],[-44,-11],[6,-30],[40,7],[52,-5],[17,-43],[23,-25],[24,9],[26,-25],[53,-37],[79,-29],[-124,-108],[-19,-33],[32,-21],[33,-51],[45,-31],[49,-54],[-8,-44],[-46,-21],[-27,-3],[-16,-19],[-9,-28],[13,-30],[50,-28],[59,5],[30,-33],[25,-98],[-121,-52],[0,-69],[6,-161],[-89,-82],[-6,-102],[-39,-106],[74,-58],[0,-34],[-114,-28],[-47,-48],[-38,-57],[-115,20],[-82,-22],[-78,-10],[-120,53],[-92,63],[-187,39],[-118,125]]],"transform":{"scale":[0.07482447546362918,-0.08000800080008001],"translate":[105.91503491958599,800]}}
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<style>
</style>
<body>
<svg></svg>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/topojson.v1.min.js"></script>
<script src="http://d3js.org/queue.v1.min.js"></script>
<script>
var cm = tributary.getCodeEditor("inlet.js")
cm.tabSize = 4;
var width = 980,
height = 800;
var path = d3.geo.path()
.projection(null);
var svg = d3.select("svg");
queue()
.defer(d3.json, "ca.json")
.defer(d3.json, "ag.json")
.await(ready);
function ready(error, ca, ag) {
svg.append("path")
.datum(topojson.feature(ca, ca.objects.ca))
.attr({
"class": "ca",
"d": path
});
svg.append("path")
.datum(topojson.feature(ag, ag.objects.agri))
.attr({
"class": "ag",
"d": path
}
});
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment