topogram icon indicating copy to clipboard operation
topogram copied to clipboard

Feature? Absolute scaling of cartogram regions

Open belg4mit opened this issue 10 years ago • 3 comments

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

belg4mit avatar Jul 19 '15 14:07 belg4mit

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!

shawnbot avatar Jul 20 '15 16:07 shawnbot

I looked through the issue list before submitting to avoid duplication. I don't see the connection with #3, nor really follow what they mean. #20 could be related, but zero is an edge case, so it might be addressed without solving it more generally.

I may try to play around with the code at some point if I can find and follow the paper.

belg4mit avatar Jul 20 '15 16:07 belg4mit

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.

shawnbot avatar Jul 20 '15 17:07 shawnbot