Skip to content

Instantly share code, notes, and snippets.

Last active October 27, 2016 18:07
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mbostock/6216797 to your computer and use it in GitHub Desktop.
Custom Cartesian Projection
license: gpl-3.0
Display the source blob
Display the rendered blob
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">
.lot {
fill: lightgray;
stroke: black;
<svg width="960" height="500"></svg>
<script src=""></script>
var svg ="svg"),
width = +svg.attr("width"),
height = +svg.attr("height");
var x = d3.scaleLinear()
.range([0, width]);
var y = d3.scaleLinear()
.range([0, height]);
var projection = d3.geoTransform({
point: function(px, py) {, y(py));
var path = d3.geoPath()
d3.json("geo.json", function(error, geo) {
if (error) throw error;
x.domain(d3.extent(geo.features, function(d) { return; }));
y.domain(d3.extent(geo.features, function(d) { return; }));
.attr("class", "lot")
.attr("d", path);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment