# Polar-centred maps by @ellis2013nz

**free range statistics - R**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

I stumbled across this page by Brilliant Maps showing settlements with no larger settlement to their north. The author noted that Helsinki was omitted by error. I wanted to address that error, and as a resident of the southern half of the globe myself, to produce a similar map with relation to the south pole.

First there’s a matter of sourcing data on cities’ and towns’ populations. There are several possible sources but I chose this dataset on opendatasoft, of all cities with a population > 1000. This doesn’t go to the tiny settlements in the original Brilliant Maps image, but it’s good enough for me.

Here’s my prep stage, downloading that data and getting a few things ready for later use in spatial transformations (coordinate reference systems that are centred on the norht and south poles) and plot polishing (abbreviating numbers, fonts, etc).

Next is the job of identifying cities that are bigger than any others to their north. This was a bit of a fiddly problem which I addressed by sorting all the cities by distrance from the north pole (highest latitude first), making a new column which is the cumulative maximum population so far, and retaining only those cities that are equal to or higher than that maximum population. This gets me a list of just 20 cities.

I then turn them into simple features objects with geometry (based on the latitude and longitude), and transform them to coordinates that will represent the world flattened out centred around the north pole, using the coordinate reference system I calculated before.

Then, I source country boundaries from the invaluable Natural Earth repository of map data (accessed via the `rnaturalearth`

R package), and give them the same transformation, and turn both data sets into a single map.

Here’s the code doing those things:

And that results in this map:

It’s a little different from the original. As expected, I am missing settlements with less than 1,000 people, and I have correctly inserted Helsinki. But there are other differences which come from ambiguities in the population size of cities. For example, if you google “Tokyo 37 million” you are prompted by Google with the frequently searched question “Is Tokyo’s population 14 or 37 million?”. It turns out the “Tokyo Metropolis” is 14m and “Tokyo metropolitan area” is 37 million.

Obviously these are numbers that depend on decisions about boundaries, which as soon as you start thinking them through are revealed as being at least to a degree arbitrary. My data source opted on the 14m side for Tokyo. New York is also defined as a smaller area than in the Brilliant Maps original. I’m not particularly concerned with (or qualified to talk about) these urban definitional matters, so I’m just going to stick to the definitions used by my data source.

My first effort at drawing these maps did the transformation on the fly using `coord_map(projection='orthographic')`

which worked ok, although it was harder (not impossible) to colour in the sea, and the constant-latitude circles I tried to draw for each city were crude and polygons. But when I tried to do the map centred on the south pole this method tripped up, and noting that `coord_map()`

is now deprecated I went the route of doing the transformation explicitly and in advance first. This gave a nicer result, particularly for the circles, and control over the bounding box of the map. So it was worth the half hour or so of cursing as I worked to understand the method. R’s power in geocomputation is growing so fast that anything on the web older than a couple of years is likely to be out of date – not necessarily wrong, but likely to miss a simpler and more powerful way of doing what you are trying.

Anyway, the “explicit transformation done before drawing the map” method worked well for any arbitrary projection, and here is the south pole version:

…which gets me this map. Nice.

This map goes well over the equator and in some ways gives a distorted view of the world; the sphere has been badly flattened and warped to show Shanghai and the south pole on the same rectangle. But I’m not going to worry about it for now.

OK that’s all folks.

**leave a comment**for the author, please follow the link and comment on their blog:

**free range statistics - R**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.