# Divide the world in longitude/latitude rectangles of similar population

I am looking for a tool that can split the Earth's surface into rectangles of similar population.

That means oceans would get a few huge rectangles, as almost nobody live there, and cities would get a lot of small rectangles. I am not super strict about all rectangles having exactly the same population, but it must be the same order of magnitude. It is OK if a few rectangles have zero population, but no rectangle must have way more population than the median.

• Must give the list of rectangles with MinLongitude/MinLatitude/MaxLongitude/MaxLatitude for each.
• Ideally I should be able to specify how many humans per rectangle, or how many rectangles I want the world to be divided into. But providing a rough choices (for instance 10k humans per rectangle or 100k humans per rectangle etc) is acceptable.
• A rectangle can not cross the 180th meridian.
• Gratis, ideally open source.
• Preferably working offline on either Linux/Windows/Mac, but websites/webapps are OK as well, and libraries for any reasonably common programming language are OK too.
• The population data it relies on must be newer than 1990.

# Context

My script calls an API that gives information for a zone specified with a MinLongitude/MinLatitude to MaxLongitude/MaxLatitude "rectangle".

Problem: The API fails if the query asks for an area that contains too many inhabitants.

I can ask for a very large rectangle in Antarctica, but in Paris the rectangle must be tiny (maximum: 1 longitude degree * 1 latitude degree).

So, I modified my script to perform tiny requests (1 degree increments of both latitude and longitude). But that leads to another problem: With 360*180=64800 rectangles, it is taking days, as each request has a large overhead, and most requests return empty results as nobody lives there. So I need something more clever.

• Maybe have a look / ask a question at gis.stackexchange.com Apr 23, 2018 at 9:50
• Sounds like you are looking for a tree map - maybe that will help you in your search. GIS is a good site; maybe also open data? Apr 23, 2018 at 11:02
• @albert: As seen at gis.meta.stackexchange.com/a/4382/1013 software recommendations are second-class citizens on the GIS site, and our site is the best place for them. Apr 24, 2018 at 2:33
• @Mawg: I guess you mean a quadtree. A dichotomy-based quadtree might be an easy (albeit non-optimal) way to implement this indeed! I just hope someone has done it already haha Apr 24, 2018 at 2:46
• I am not so sure that I, but +1 for introducing me to a new concept :-) "a tree data structure useful to store 2D positional data" ... and ... "A quadtree is a tree data structure in which each internal node has exactly four children". Let the OP decide; being aware of both of of these will probably help his search Apr 24, 2018 at 5:57