Algorithm (and tools) to create a weighted-cartogram from a shapefile?
Asked Answered
F

2

7

What algorithm can I use to produce a weighted-cartogram such as the one below: http://www.brainpickings.org/index.php/2010/04/15/cartograms/ ?

I can generate a shapefile plot using code from R, .NET libraries and also using PostGIS. However I can't find the search terms to use to find an implementation of the algorithm used to produce these warped shapefile plots. Not necessarily looking to plot only world maps, so must be able to work with an arbitrary shapefile.

Franklinfranklinite answered 17/4, 2014 at 10:24 Comment(6)
I found some slides here on similar topics but none talk about how to scale a 'real-world' shapefile : i11www.iti.uni-karlsruhe.de/_media/teaching/winter2012/algo2/…Franklinfranklinite
It seems there is a list of cartogram algorithms on Wikipedia at en.wikipedia.org/wiki/Cartogram — I'm going to read over those and see if any of the useful links take me anywhereFranklinfranklinite
Need to get to a library but it seems that this book may contain some information too: amazon.co.uk/…Franklinfranklinite
Seems that 'Diffusion-based method for producing density-equalizing maps' might hold the answer, although the implementation is not clear : pnas.org/content/101/20/7499.full via viewsoftheworld.net/?p=3328Franklinfranklinite
These are called area cartograms, and there's a JS/D3 implementation here for you to reference (choose a dataset from the drop-down menu to get it to render).Nubile
Andy, please add that as a full answer : )Franklinfranklinite
N
4

So as mentioned in the OP's comments, these are called area cartograms. The neatest lil implementation I know of is cartogram.js, which relies on the magical D3 library. If that page ever happens to go down, you should be able to find a similar page by Googling "D3 area cartograms", and if that doesn't get you anywhere then the original paper on the topic was Dougenik 1985.

Nubile answered 17/4, 2014 at 17:42 Comment(0)
G
4

The D3.js answer, by Andy, is excellent, however, just for completeness, there is an implementation here, Cartogram algorithm, which comes from a Python plugin for the excellent open source GIS application, QGIS. The original paper and algorithm are cited in the comments. The full source code directory for the QGIS plugin is: https://code.google.com/p/ftools-qgis/source/browse/trunk/cartogram/?r=115

I realize that you asked for C#, and there are some QGIS geometry objects in the code, but the TransformGeometry method does illustrate how the algorithm works, QGIS reads shapefiles, and in case you wanted to do any other GIS style processing, QGIS would be a good option.

Grandpapa answered 19/4, 2014 at 9:45 Comment(1)
This looks really interesting. I'm going to have some time to look into this next weekend and I'll probably post back then. Thanks JohnFranklinfranklinite

© 2022 - 2024 — McMap. All rights reserved.