# Custom world map how to draw country shapes

**URL:** https://discourse.processing.org/t/custom-world-map-how-to-draw-country-shapes/6712
**Category:** Libraries
**Created:** [December 17, 2018, 6:34pm UTC](https://discourse.processing.org/t/custom-world-map-how-to-draw-country-shapes/6712 "2018-12-17T18:34:44Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![carlesgutierrez](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/carlesgutierrez/32/2844_2.png) [@carlesgutierrez](https://discourse.processing.org/u/carlesgutierrez)
#### Post date: [December 17, 2018, 6:34pm UTC](https://discourse.processing.org/t/custom-world-map-how-to-draw-country-shapes/6712/1 "2018-12-17T18:34:44Z")

</div>

Hi all,  
I’m wondering if anyone has an idea how to create a dynamic world map… I would love to get all the countries as vector of polygon, then redraw them in different shapes styles and positions.

After this I want to play with all them in [Box2d library.](https://github.com/shiffman/Box2D-for-Processing/blob/master/Box2D-for-Processing/dist/box2d_processing/examples/Polygons/Polygons.pde)…

I’ve been looking at [MapThing library](https://github.com/jreades/MapThing), has function to draw the outline as a simplified contour.  
`worldSimplified.project(this);`  
But I’ve not a clear way how to re-code it in my own to be able to manipulate them later on.

Any tips so welcome.

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [December 19, 2018, 12:09am UTC](https://discourse.processing.org/t/custom-world-map-how-to-draw-country-shapes/6712/2 "2018-12-19T00:09:02Z")

</div>

Are you looking for a data source for country vectors, or do you have that data already? If so, what is it / what does it look like?

I believe the three available wrappers for JBox2D are

- “Box2D for Processing”
- “Fisica”
- “LiquidFun”

However, I _think_ none of the Box2D-based systems are going to work if you are hoping to import national boarder outlines as Custom Polygons.

> “Convex shapes only!” (link to video at time 225)

[![](https://img.youtube.com/vi/V95dzuDw0Jg/maxresdefault.jpg "5.7: Complex Shapes in Box2D - The Nature of Code") ](https://www.youtube.com/watch?v=V95dzuDw0Jg&t=225)

Box2D doesn’t handle convex polygons, and very _very_ few nations have convex boarders – most are at least partially concave. For example, even a very simple outline of the United States of America is concave on the eastern seaboard, the northern border, and the Gulf of Mexico.

So you either need a different collision system – or you need to model each national boarder as an assemblage of multiple simple convex shapes.

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [December 19, 2018, 12:26am UTC](https://discourse.processing.org/t/custom-world-map-how-to-draw-country-shapes/6712/3 "2018-12-19T00:26:21Z")

</div>

…yep, it looks like the thing to do is decompose into convex polygons.

Check out the toy bunny rabbit in this [Phaser demo based on Box2D](https://phaser.io/examples/v2/box2d/load-polygon) – there are faint lines tracing the way that it is broken down into convex shapes so that box2d can model collisions:

 ![17%20PM](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/d/d682377c05d8248c33f67e6d92420b85d52edec7.jpeg)

Related discussion:

> <https://stackoverflow.com/questions/8543105/is-there-any-way-to-draw-the-concave-polygon-in-box2d-and-detect-the-collision-w>

…and an old related project based on SVG map data import:

[https://www.kaotec.org/dataviz-using-box2d/](https://www.kaotec.org/dataviz-using-box2d/)
