Skip to content

Instantly share code, notes, and snippets.

@biovisualize
Last active November 4, 2015 07: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 biovisualize/583d18e90c37e5bf79d6 to your computer and use it in GitHub Desktop.
Save biovisualize/583d18e90c37e5bf79d6 to your computer and use it in GitHub Desktop.
antimeridian cutting problem
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<style>
</style>
</head>
<body>
<script>
// this gepjson is supposed to look like this
// http://bl.ocks.org/d/ec4cebc0afcf170091b2
// http://geojson.io/#id=gist:biovisualize/e1138c4419665f0a1d2b&map=2/20.0/0.0
var polygonData = {
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[ -100, -20 ],
[ -100, 20 ],
[ 100, 20 ],
[ 100, -20 ],
[ -100, -20 ]
]
]
},
"properties": {}
};
var width = 1000;
var height = 500;
var projection = d3.geo.equirectangular()
.scale(100)
.translate([width / 2, height / 2])
.rotate([0, 0])
.center([0, 0])
.precision(0);
var path = d3.geo.path()
.projection(projection);
var svg = d3.select("body").append("svg")
.attr({
width: width,
height: height
});
svg.append('path')
.datum(polygonData)
.attr({
d: path,
fill: 'orange',
opacity: 0.5
});
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment