Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8742121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:26:37+00:00 2026-06-13T11:26:37+00:00

I’m using the standard AlbersUSA projection within d3. The one thing I’m running into

  • 0

I’m using the standard AlbersUSA projection within d3.

The one thing I’m running into though is that since Alaska and Puerto Rico are outside the “rectangle” drawn by the contiguous states, I can’t quite maximize my zoom factor to fit within a smaller viewport.

Ideally I’d like to move Puerto Rico below Louisiana and potentially swap places with Hawaii and Alaska, which would give me better bounds to work with.

Looking over the documentation, I see the AlbersUSA composite was created with the following function:

function albersUsa(coordinates) {
  var lon = coordinates[0],
      lat = coordinates[1];
  return (lat > 50 ? alaska
      : lon < -140 ? hawaii
      : lat < 21 ? puertoRico
      : lower48)(coordinates);
}

How can I modify this function (or effectively create my own) so that I can move the states around without having to worry about augmenting the GeoJSON data itself?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T11:26:38+00:00Added an answer on June 13, 2026 at 11:26 am

    (I haven’t tried this)

    1. Copy the code for d3.geo.albersUsa out of the d3 source (code is included at bottom of this post).

    2. Modify the name: d3.geo.myAlbersUsa = function() { ... }

    3. Look inside the function albersUsa.translate. That’s where the 3 states are moved to their “artificial” positions. Eg alaska.translate([dx - 400 * dz, dy + 170 * dz]);

    4. Tweak these numbers (400 and 170) until it moves to where you want it to be (start with small changes, like +/- 10).

    5. For any path that you’re drawing the data into, you need to specify its projection to be your custom projection: path.projection(d3.geo.myAlbersUsa())

    From the D3 source, this is the code you need to copy/paste in step 1:

    // A composite projection for the United States, 960x500. The set of standard
    // parallels for each region comes from USGS, which is published here:
    // http://egsc.usgs.gov/isb/pubs/MapProjections/projections.html#albers
    // TODO allow the composite projection to be rescaled?
    d3.geo.albersUsa = function() {
      var lower48 = d3.geo.albers();
    
      var alaska = d3.geo.albers()
          .origin([-160, 60])
          .parallels([55, 65]);
    
      var hawaii = d3.geo.albers()
          .origin([-160, 20])
          .parallels([8, 18]);
    
      var puertoRico = d3.geo.albers()
          .origin([-60, 10])
          .parallels([8, 18]);
    
      function albersUsa(coordinates) {
        var lon = coordinates[0],
            lat = coordinates[1];
        return (lat > 50 ? alaska
            : lon < -140 ? hawaii
            : lat < 21 ? puertoRico
            : lower48)(coordinates);
      }
    
      albersUsa.scale = function(x) {
        if (!arguments.length) return lower48.scale();
        lower48.scale(x);
        alaska.scale(x * .6);
        hawaii.scale(x);
        puertoRico.scale(x * 1.5);
        return albersUsa.translate(lower48.translate());
      };
    
      albersUsa.translate = function(x) {
        if (!arguments.length) return lower48.translate();
        var dz = lower48.scale() / 1000,
            dx = x[0],
            dy = x[1];
        lower48.translate(x);
        alaska.translate([dx - 400 * dz, dy + 170 * dz]);
        hawaii.translate([dx - 190 * dz, dy + 200 * dz]);
        puertoRico.translate([dx + 580 * dz, dy + 430 * dz]);
        return albersUsa;
      };
    
      return albersUsa.scale(lower48.scale());
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
I'm making a simple page using Google Maps API 3. My first. One marker
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.