The Average Thing #5: The Average Place pt.2

In [1]:
%matplotlib inline

The Average Thing #5: The average place pt. 2

This is a quick follow up on the last post: We're going to check our math and look at an alternate way of finding the average location: using the Mercator Projection.

Earlier, we saw that the origin of the average object was somewhere in the Hudson Bay in Canada. This seemed at odds with my intuition. I also had a feeling that the reason this result seemed weird was because my mental representation of the earth was not spherical, but cylindrical (e.g., the Mercator Projection).

To demonstrate this, let's test the simple case where we find the point between the middle of Canada and the UK:

In [6]:
canada = country_locations['Canada']
uk = country_locations['England']

#convert to radians
canada = to_radians(canada)
uk = to_radians(uk)
#convert to cartesian
canada = to_cartesian(canada)
uk = to_cartesian(uk)
#find average
averagepoint = ((canada[0]+uk[0])/2, (canada[1]+uk[1])/2, (canada[2]+uk[2])/2)

print to_latlong(averagepoint)
(68.71255890231265, -45.65693500322893)
In [7]:
from IPython.display import IFrame

jUuMCJX!5e0!3m2!1sen!2sus!4v1462973875452''', width=800, height=600)

To visualize how this is really the mid point, we can look at that point on a 3D globe (external link):

The above visualization makes it clear how my intuition differed from reality - the shortest distance between the middle of Canada and the UK is not across the Atlantic, but crosses Greenland.

But let's, for a moment, be flat-earthers, and stick to our flat representation of the earth, like we do whenever we use a map or chart. In this case, we simply average the latitude and longitudes of all the points (see:

In [10]:
latlon_no_na = data.loc[data['GeoLocations'].isnull() == False]['GeoLocations']
latlon_no_na = latlon_no_na[latlon_no_na != '']
avelatlon = reduce(lambda x,y: (x[0] + y[0], x[1] + y[1]), latlon_no_na)

avelatlon = (avelatlon[0]/len(latlon_no_na), avelatlon[1]/len(latlon_no_na))
(49.76023781406744, -68.28145709782275)

Constructing the map this way gives us a point somewhere in Quebec, which is in line with how we might think of the average point if the world was flat:

In [11]:
KwMTYnNTMuMiJX!5e0!3m2!1sen!2sus!4v1462977105095''', width = 800, height = 600)