Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature? Absolute scaling of cartogram regions #21

Open
belg4mit opened this issue Jul 19, 2015 · 3 comments
Open

Feature? Absolute scaling of cartogram regions #21

belg4mit opened this issue Jul 19, 2015 · 3 comments

Comments

@belg4mit
Copy link

Would it be possible for the cartogram to scale features absolutely as well as relatively? Only the latter seems to occur at the moment that is, total area seems to preserved as U.S. states are scaled against one another. For example, with the dataset being presented in the attached image, the US should being nearly twice as large as it actually is, yet the cartogram is roughly the same size as the unmodified map.
usef2010cartogram-scalingref

@shawnbot
Copy link
Owner

This is basically a dupe of #20, and really of #3. Unfortunately I haven't had much time to work on this library in a couple of years, so if you're interested in helping out, pull requests are welcome!

@belg4mit
Copy link
Author

belg4mit commented Jul 20, 2015 via email

@shawnbot
Copy link
Owner

Here is where I got when I last thought about the problem.

One solution is something along the lines of using the area (in pixels) of the features as the basis for the scale range. E.g.

var path = d3.geo.path();
var areas = features.map(path.area);
var areaRange = d3.extent(areas);
var scale = d3.scale.linear()
  .domain(valueDomain)
  .range(areaRange);

Another way of doing it would be to find the total area of the features, then proportionally scale the output range in such a way that you end up with the same total area. That's a slightly more complicated process, but might be possible to generalize within the library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants