Skip to content

Instantly share code, notes, and snippets.

@martgnz
Last active January 22, 2017 19:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martgnz/a4fe26c19a646889017c3a322afb1a7a to your computer and use it in GitHub Desktop.
Save martgnz/a4fe26c19a646889017c3a322afb1a7a to your computer and use it in GitHub Desktop.
NY State Plane
license: mit
border: none

A quick test of d3.geo.statePlanes using Spam.

This projection centers the map on a given state through its code. In this case New York with d3.geo.statePlane('NY').

<!DOCTYPE html>
<meta charset="utf-8" />
<body>
<script src="https://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="https://d3js.org/topojson.v1.min.js"></script>
<script src="https://unpkg.com/rbush@1.4.3/rbush.js"></script>
<script src="https://unpkg.com/spamjs@1.1.0/spam.min.js"></script>
<script src="https://cdn.rawgit.com/gka/d3-geo-state-plane/master/state-plane.js"></script>
<script type='text/javascript'>
d3.json("/mbostock/raw/4090846/us.json", function(error, d) {
topojson.presimplify(d)
var map = new StaticCanvasMap({
element: "body",
width: 960,
height: 500,
projection: d3.geo.statePlane('NY'),
data: [{
features: topojson.feature(d, d.objects["states"]),
static: {
paintfeature: function(parameters, d) {
parameters.context.lineWidth = 1
parameters.context.strokeStyle = "rgb(255,255,255)"
parameters.context.fillStyle = "rgb(30, 30, 30)"
parameters.context.stroke()
parameters.context.fill()
}
}
}]
})
map.init()
})
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment