Skip to content

Instantly share code, notes, and snippets.

@mashbridge
Created October 25, 2013 07:38
Show Gist options
  • Save mashbridge/7150845 to your computer and use it in GitHub Desktop.
Save mashbridge/7150845 to your computer and use it in GitHub Desktop.

The size of Wales.

To build wales.json:

curl -O "http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_admin_0_map_subunits.zip" && unzip ne_10m_admin_0_map_subunits.zip && ogr2ogr -f GeoJSON -where "SUBUNIT IN ('Wales')" wales.subunit.json ne_10m_admin_0_map_subunits.shp && topojson --id-property su_a3 -p name=NAME -p name -o wales.json wales.subunit.json

<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/topojson.v1.min.js"></script>
<style>
html, body, #map-canvas {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
.wales path {
fill: #FF0000;
stroke: #FF0000;
stroke-width: 2;
stroke-opacity: 0.3;
fill-opacity: 0.2;
}
</style>
</head>
<body>
<div id="map-canvas"></div>
<script type="text/javascript">
function initGoogleMaps() {
var mapOptions = {
center: new google.maps.LatLng(54.239551,-5.405273),
zoom: 6,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
}
google.maps.event.addDomListener(window, 'load', initGoogleMaps);
d3.json("wales.json", function(error, json) {
var overlay = new google.maps.OverlayView();
overlay.onAdd = function() {
var layer = d3.select(this.getPanes().overlayLayer).append("div")
.attr("class", "wales");
var svg = layer.append("svg")
.attr("width", 100000)
.attr("height", 100000);
var wales = svg.append("g")
.attr("class", "wales");
overlay.draw = function() {
var d3Prj = this.getProjection();
var gPrj = function (c) {
var latLng = new google.maps.LatLng(c[1], c[0]);
var p = d3Prj.fromLatLngToDivPixel(latLng);
return [p.x, p.y];
}
var path = d3.geo.path().projection(gPrj);
wales.selectAll("path")
.data(topojson.feature(json, json.objects.wales).features)
.attr("d", path)
.enter().append("path")
.attr("d", path);
};
};
overlay.setMap(map);
});
</script>
</body>
</html>
Display the source blob
Display the rendered blob
Raw
{"type":"Topology","objects":{"wales":{"type":"GeometryCollection","geometries":[{"type":"MultiPolygon","properties":{"name":"Wales"},"arcs":[[[0]],[[1]],[[2]]]}]}},"arcs":[[[2460,9474],[43,-1],[67,7],[28,-19],[56,-43],[50,-52],[36,-60],[14,-65],[17,-27],[33,-30],[20,-38],[-19,-53],[-31,-12],[-38,13],[-76,54],[-77,112],[-37,34],[-33,7],[-109,-7],[-23,11],[-65,86],[0,34],[100,70],[44,-21]],[[7733,9439],[482,-246],[56,-51],[46,-61],[28,-23],[12,19],[0,98],[67,-26],[141,-21],[35,-11],[241,-153],[124,-108],[17,-20],[17,-29],[8,-43],[-5,-22],[-10,-15],[-139,-70],[-13,-11],[-5,-17],[1,-12],[1,-4],[19,-26],[184,-156],[19,-21],[100,-176],[25,-65],[25,-86],[2,-18],[-1,-19],[8,-25],[17,-28],[93,-84],[28,-51],[18,-13],[28,-10],[141,-16],[153,-74],[2,0],[8,-40],[24,-46],[6,-16],[3,-19],[-2,-79],[-3,-20],[-15,-16],[-23,-10],[-50,-9],[-38,-14],[-76,-46],[-30,-8],[-36,8],[-23,9],[-198,163],[-20,9],[-44,10],[-49,1],[-147,-35],[-33,-3],[-26,3],[-17,8],[-16,11],[-63,61],[-17,7],[-44,8],[-68,-3],[-42,-15],[-190,-115],[-15,-6],[-19,-3],[-15,-5],[-47,-29],[-22,-20],[-20,-27],[-31,-52],[-25,-21],[-25,-13],[-39,-13],[-13,-16],[-6,-22],[8,-41],[8,-23],[9,-21],[4,-18],[-4,-20],[-20,-25],[-51,-39],[-13,-13],[-23,-29],[-7,-17],[-2,-29],[1,-24],[45,-111],[0,-1],[39,-33],[64,-23],[116,-8],[17,-6],[11,-9],[26,-41],[18,-15],[20,-11],[105,-12],[89,-23],[22,-10],[6,-5],[38,-54],[19,-17],[17,-12],[65,-26],[6,-13],[-5,-15],[-24,-40],[-23,-17],[-23,-11],[-73,-5],[-24,-4],[-15,-8],[-14,-11],[-11,-17],[-18,-46],[-26,-42],[-4,-19],[-4,-33],[4,-61],[-13,-46],[-12,-25],[-17,-13],[-71,-34],[-14,-11],[-11,-19],[-7,-27],[-10,-67],[-6,-22],[-8,-16],[-24,-28],[-32,-21],[-102,-51],[-14,-11],[-11,-15],[-7,-21],[-1,-28],[4,-22],[15,-33],[29,-42],[9,-15],[5,-16],[0,-19],[-5,-16],[-21,-29],[1,-13],[17,-10],[40,-2],[28,4],[22,8],[14,12],[12,14],[19,31],[13,13],[15,10],[105,47],[72,57],[18,7],[19,1],[18,-5],[94,-85],[13,-21],[5,-19],[-3,-18],[-19,-24],[-28,-27],[-98,-70],[-35,-67],[-25,-14],[-288,-14],[-39,-13],[-98,-55],[-173,-55],[-16,-9],[-26,-24],[-44,-59],[-6,-19],[-1,-19],[0,-19],[7,-38],[6,-22],[11,-24],[10,-16],[12,-14],[13,-13],[128,-68],[96,-73],[135,-76],[98,-87],[26,-18],[425,-27],[3,0],[6,-47],[-9,-18],[-24,-26],[-76,-40],[-26,-23],[-19,-33],[-13,-33],[1,-8],[10,-52],[12,-21],[18,-16],[94,-23],[17,-8],[10,-13],[0,-16],[-22,-21],[-23,-10],[-128,-4],[-36,-10],[-15,-9],[-11,-9],[-26,-33],[-12,-12],[-15,-11],[-52,-23],[-15,-11],[-12,-13],[-10,-17],[-18,-57],[-20,-29],[-153,-178],[-5,-21],[6,-22],[30,-32],[23,-7],[22,1],[19,3],[18,-5],[7,-15],[-9,-27],[-15,-18],[-18,-14],[-99,-27],[-34,-16],[-9,-15],[3,-19],[28,-27],[56,-31],[3,-6],[-4,-7],[-19,-12],[-12,-14],[-12,-18],[-16,-42],[-23,-84],[2,-12],[5,-12],[28,-10],[35,-25],[66,-59],[10,-18],[8,-23],[2,-40],[-5,-26],[6,-37],[7,-27],[108,-163],[1,-2],[85,-97],[111,-81],[6,-7],[9,-13],[5,-16],[5,-36],[14,-21],[23,-24],[80,-57],[31,-12],[41,-1],[26,4],[39,14],[112,67],[37,12],[42,5],[367,-266],[40,-41],[9,-16],[50,-47],[10,-14],[16,-29],[10,-13],[18,-12],[23,-7],[69,4],[29,-3],[26,-11],[69,-55],[70,-36],[38,18],[6,3],[-27,-70],[-81,-103],[-13,-41],[-6,-30],[1,-35],[15,-33],[24,-43],[-1,-27],[-13,-37],[-12,-20],[-25,-31],[-2,-20],[5,-25],[33,-66],[28,-86],[12,-27],[7,-23],[0,-16],[-15,-18],[-60,-20],[-9,-12],[2,-15],[20,-25],[19,-32],[2,-46],[27,-101],[-106,-103],[-73,-47],[-178,-34],[-141,-79],[-69,-39],[-159,-46],[-317,-18],[-49,16],[-29,34],[-20,35],[-20,15],[-35,-22],[-98,-100],[-21,-31],[-218,-114],[-10,-3],[-47,-13],[-62,-39],[-98,-82],[-13,-20],[-22,-57],[-16,-23],[-27,-14],[-53,-6],[-22,-13],[-1,-1],[47,-104],[-26,-105],[-66,-62],[-73,19],[-55,6],[-265,-91],[-938,70],[-68,32],[-67,75],[-111,124],[-219,149],[-52,4],[-69,-27],[-85,35],[-74,60],[-39,49],[-5,22],[7,8],[12,3],[10,4],[-28,96],[-10,25],[-27,67],[-42,81],[-45,65],[-30,26],[-66,35],[-34,36],[-59,93],[-34,30],[-50,11],[-119,-12],[-284,-28],[-54,-19],[-50,-26],[-33,-30],[-4,-46],[29,-48],[39,-47],[27,-42],[-156,0],[0,-13],[-18,-22],[-21,-9],[-10,26],[-10,19],[-25,15],[-30,11],[-25,4],[-12,-11],[-35,-47],[-17,-9],[-25,6],[-39,25],[-93,18],[-36,2],[-40,-15],[-39,-30],[-53,-52],[-36,-18],[-38,8],[-42,22],[-34,3],[-14,-52],[-48,2],[-222,77],[-66,4],[-12,17],[-7,14],[-8,36],[71,43],[-9,52],[-34,63],[-1,75],[129,34],[14,16],[40,60],[25,27],[23,-37],[-23,0],[0,-30],[25,-15],[26,-21],[116,31],[192,10],[179,37],[79,110],[2,33],[-3,26],[0,8],[-18,9],[-45,-44],[-31,-18],[-42,-4],[-149,13],[-203,92],[-54,-30],[-296,-36],[-81,25],[-101,66],[-91,86],[-48,90],[155,-17],[68,7],[35,44],[-68,-4],[-69,14],[-58,35],[-35,58],[11,11],[22,33],[19,46],[-1,44],[-26,34],[-24,-16],[-29,-52],[-21,-16],[-30,-40],[-24,-11],[-38,8],[-32,23],[-32,36],[-73,-10],[-13,-34],[30,-46],[56,-47],[-129,-56],[-143,-5],[-283,31],[-109,-9],[-135,-30],[-23,-5],[-123,-72],[-8,-121],[-34,-5],[-8,-9],[0,-19],[-9,-37],[-69,-139],[-34,10],[-51,35],[-26,-15],[-65,-55],[-334,7],[-58,-11],[-58,-33],[-33,-36],[-30,-44],[-33,-35],[-71,-26],[-32,-47],[-34,-12],[-18,5],[-39,26],[-245,65],[-91,53],[35,51],[-55,96],[-185,38],[-72,67],[23,34],[289,-34],[-8,17],[-10,37],[-8,16],[55,1],[99,-27],[53,-8],[51,11],[126,59],[182,31],[92,51],[38,7],[50,-22],[0,31],[-108,86],[-21,119],[62,100],[144,29],[0,36],[-44,-24],[-109,-37],[-211,-16],[-47,-23],[62,0],[45,-20],[17,-44],[-21,-73],[53,-38],[-13,-55],[-56,-49],[-292,-56],[-81,-2],[-523,57],[-66,-21],[37,-79],[-44,-43],[-53,2],[8,53],[0,31],[-186,116],[-72,18],[80,1],[53,9],[42,24],[44,51],[53,42],[127,20],[64,23],[59,49],[12,47],[-19,123],[-4,76],[-16,73],[-31,60],[-52,39],[-26,-33],[-67,47],[-148,17],[-67,36],[-53,-32],[-209,-35],[-73,0],[25,18],[26,13],[0,36],[-13,22],[-7,15],[9,16],[37,18],[0,30],[-30,62],[36,30],[135,8],[70,21],[113,95],[49,21],[115,14],[153,46],[119,84],[11,126],[53,0],[0,31],[-44,31],[5,33],[42,25],[62,11],[101,-6],[44,-10],[200,-87],[72,0],[108,36],[-26,67],[71,-10],[145,-47],[81,-10],[35,20],[-6,48],[-17,56],[1,43],[29,19],[125,18],[73,41],[54,54],[92,122],[69,61],[52,1],[124,-79],[-9,145],[144,56],[464,-14],[43,14],[25,25],[18,33],[25,29],[111,28],[75,41],[72,55],[112,107],[54,29],[62,13],[77,4],[69,17],[446,308],[218,250],[110,171],[50,111],[34,207],[31,112],[42,101],[42,69],[-19,45],[-9,60],[6,57],[22,42],[31,5],[82,-35],[39,-7],[65,20],[193,114],[0,36],[-102,-1],[-192,-54],[-103,-15],[-57,38],[-172,188],[-42,75],[12,122],[61,121],[79,94],[67,37],[13,14],[18,66],[8,20],[15,7],[40,12],[154,96],[48,49],[-100,-9],[-64,-41],[-64,-12],[-286,278],[-72,120],[-18,45],[11,40],[65,17],[43,35],[-9,76],[-30,75],[-17,33],[1,69],[8,33],[24,20],[223,126],[-27,10],[-12,8],[-12,19],[-43,-38],[-43,-23],[-37,7],[-30,54],[-97,-58],[-103,-6],[-213,27],[-271,-66],[-62,-31],[-75,-35],[-261,2],[-77,-32],[-71,-49],[-133,-123],[14,-12],[9,-21],[-60,-29],[-36,-56],[-1,-63],[46,-52],[-48,-40],[-28,-18],[-27,-9],[-45,4],[-53,50],[-80,23],[-72,46],[-43,10],[-45,-8],[-26,-20],[-22,-22],[-26,-16],[-84,-18],[-210,18],[-55,-28],[-53,-49],[-53,-20],[-58,30],[39,45],[4,22],[-15,30],[23,24],[54,79],[521,480],[57,25],[71,5],[70,16],[73,31],[302,186],[74,100],[246,126],[31,64],[16,88],[7,204],[11,57],[25,20],[25,-10],[11,-34],[15,-31],[32,39],[28,56],[4,22],[150,143],[42,23],[67,23],[50,54],[78,127],[85,81],[99,52],[110,26],[118,8],[32,-8],[30,-14],[28,-8],[48,26],[81,31],[88,19],[129,85],[410,133],[128,0],[-38,90],[-110,89],[-29,59],[69,-7],[73,-17],[66,-30],[48,-47],[74,31],[81,-21],[78,-55],[61,-73],[59,-29],[428,9],[149,27],[715,277],[156,4],[143,-55],[79,-49],[34,-49],[43,-39]],[[4158,9370],[47,-9],[48,5],[86,21],[47,4],[22,11],[33,48],[22,11],[25,-6],[48,-25],[16,-5],[110,3],[52,-9],[46,-28],[-77,-66],[-130,-191],[-90,-41],[-93,-14],[-95,-37],[-88,-55],[-73,-64],[-13,-15],[-8,-13],[-2,-19],[0,-36],[-4,-39],[-11,-5],[-16,5],[-132,-75],[-59,-58],[-239,-112],[-39,-11],[-47,7],[-96,34],[-1,-11],[-23,-16],[-30,-11],[-23,8],[-5,28],[2,45],[6,42],[9,18],[29,22],[43,45],[20,46],[-40,21],[-57,-22],[-82,-94],[-55,-18],[-4,16],[-124,85],[-11,3],[-30,-6],[-11,3],[-2,13],[5,40],[-3,14],[1,14],[-4,36],[-13,36],[-76,57],[-124,191],[-68,66],[0,37],[22,50],[8,74],[-2,107],[19,163],[-9,71],[-38,73],[66,38],[481,128],[47,1],[260,-34],[71,-2],[143,-64],[37,-27],[18,-58],[10,-59],[12,-27],[-3,-13],[46,-28],[55,-24],[20,-1],[3,-25],[-4,-34],[-1,-29],[13,-12],[4,-12],[59,-55],[21,-57],[7,-41],[16,-27]]],"transform":{"scale":[0.0002664166570657013,0.0002042928902890254],"translate":[-5.310943162999905,51.38422272300012]}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment