Flow-Based-Cartograms / go_cart

High-performance software to produce flow-based cartograms.
https://go-cart.io/
Other
113 stars 33 forks source link

Cartogram generation gets stuck in ffb_integrate() #3

Closed byambajav closed 6 years ago

byambajav commented 6 years ago

The provided examples run fine on my machine. But when I try to run the cartogram generation with my data, it gets stuck in the ffb_integrate() step. Do I need to pre-process my data to satisfy some conditions or is it a bug in the tool?

pratyushmore commented 6 years ago

Hi @byambajav ,

We use ArcGIS' convention that polygons whose points are provided in a clock-wise direction are treated as positive areas, whereas those whose points are provided in an anti-clockwise direction are treated as negative areas. In your sample data, I believe Polygon 14 is provided in an anti-clockwise direction, which causes its area to be negative. This leads to an overall negative average density, which prevents the integrator from converging.

Further details and mathematics are provided in the code. Link to specific file and line:

https://github.com/Flow-Based-Cartograms/go_cart/blob/53dbf84cccb3b3351c83e6a236890a03fa36966f/cartogram_generator/fill_with_density.c#L177

Hope this helps!

pratyushmore commented 6 years ago

I have further verified that this is the problem. When I remove the anti-clockwise check, I obtain the following figure, which is consistent with your data:

cartogram

byambajav commented 6 years ago

Hi @pratyushmore,

After fixing my data to conform to the conventions (clockwise for outer polygons, anti-clockwise for holes), I was able to run the cartogram generation.

Thanks for your help.