Skip to content

Instantly share code, notes, and snippets.

@bricedev
Last active August 29, 2015 14:24
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 bricedev/b485239a37ca57722603 to your computer and use it in GitHub Desktop.
Save bricedev/b485239a37ca57722603 to your computer and use it in GitHub Desktop.
Europe

Europe projection

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>
<meta charset="utf-8">
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/topojson/1.6.19/topojson.min.js"></script>
<script>
var width = 960,
height = 700;
var projection = d3.geo.conicConformal()
.rotate([-10, 0])
.center([0, 53])
.parallels([29.5, 45.5])
.scale(1100)
.translate([width / 2, height / 2]);
var path = d3.geo.path()
.projection(projection);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
d3.json("europe.json", function(error, europe) {
if (error) throw error;
console.log(europe);
svg.selectAll(".countries")
.data(topojson.feature(europe, europe.objects.countries).features)
.enter().append("path")
.attr("class", "countries")
.style("fill", "#e2e2e2")
.style("stroke","#9a9a9a")
.style("stroke-width","0.3px")
.attr("d", path);
});
d3.select(self.frameElement).style("height", height + "px");
</script>

ogr2ogr
-f GeoJSON
-where "Continent IN ('Europe')"
countries.json
ne_10m_admin_0_countries.shp

topojson
-o topoeurope.json
--id-property SU_A3
--
countries.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment