Skip to content

Instantly share code, notes, and snippets.

Last active October 26, 2015 20:29
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mikeskaug/4540864bb185987d5820 to your computer and use it in GitHub Desktop.
Shaded Relief with AlbersUsa Projection
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<script src="" charset="utf-8"></script>
<script src=""></script>
<script type="text/javascript">
var w = 900;
var h = 500;
var projection = d3.geo.albersUsa()
.translate([w/2-100, h/2+20])
var path = d3.geo.path()
var svg ="body")
.attr("width", w)
.attr("height", h)
d3.json("us-land.json", function(error, us) {
if (error) throw error;
var defs = svg.append("defs");
.attr("id", "land")
.attr("d", path)
.style("fill", "none");
.attr("id", "clip1")
.attr("xlink:href", "#land");
//append and clip the shaded relief bitmap
//scale factor and translation determined through trial and error
.attr("width", 900*0.8)
.attr("height", 600*0.8)
.attr("clip-path", "url(#clip1)")
.attr("xlink:href", "lower48.png");
.attr("id", "clip2")
.attr("xlink:href", "#land");
.attr("width", 300*0.62)
.attr("height", 202*0.62)
.attr("clip-path", "url(#clip2)")
.attr("xlink:href", "alaska.png");
.attr("xlink:href", "#land");
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment