A Gravitational Map of Cities


(Andy Wootton) #1

I’m going to give this a go to get my rusty coding skills moving. I’ve never programmed with GUIs. the web, networks, databases, objects or any of the languages or tools I’m likely to use - so it should be fine, right?

This is a slightly expanded version of my previously stated question:


A 'gravitational map' of UK cities
(Andy Wootton) #2

I haven’t done software development ‘on the Internet’ before, so I have much to learn. I’ve been locked inside a corporate firewall for 20 years, as a Business Analyst in a .Net Agile team for the last few, while using Free software for almost as long at home. I believe in Open Standards and still have a sufficiently open mind about Free and Open Source culture to want to use it here, if at all possible.

I’m taking a Lean/Agile ‘what’s the least I could do to get me there?’, where ‘there’ is only partly defined.

I’ve been drawing on a white-board, off-line and decided:

Product Vision:
A model of cities, represented on a conventional geographical map, but imagining that each city (population centre) has a mass and representing the gravitational force vectors between points at the centre of these fixed masses. The product is an initial investigation into whether, under a more complex model, such gravitational tidal forces might be responsible for tidal flows of populations e.g. Techies from London to Birmingham

At this point, it is unclear to the author whether the product is social science, technology or audience participation performance art.

User-Stories:

As a MapGeek, I want the initial output to be a map, showing an arrow from the centre of each population centre, representing the gravitation force vector acting on it.

As a MapGeek I would like to be able to set the MinimumPopulationCentreSize. (Smaller population centres to be ignored at any resolution) so that overhead of recalculating forces and map detail can be set.

As a DataGeek I want a list of population centres in ‘mass’ order (mass is still to be defined, so the data needs to be sortable. ‘Mass’ candidates include population size, land area, income, housing prices & combinations.) so that large cities can be addressed while data is still being collected

As a DataGeek I may need the ability to play with the definition of a PopulationCentre if characterisics turn out to be irregular across cities so that e.g. Sutton Park being inside the City of Birmingham doesn’t scew results.

Dev Tasks:

Get data about cities:


51 cities in England, 7 in Scotland, 6 in Wales, and 5 in Northern Ireland. Dealing with the single land-mass of England, Scotland & Wales seems approriate. 10 cities would probably be sufficient to get representative results.
Get 10 Eng, Sco, Wal cities
Get all Eng, Sco, Wal cities
(Later? Get more at ‘lower resolution’)

[Alternative: https://en.wikipedia.org/wiki/Metropolitan_borough]

Get the distances between the n population centres that are to be mapped so that the gravitational field vectors can be calculated. This is a triangle, as any owner of an AA Atlas knows, because distances are the same both ways.
Get 10 Eng, Sco, Wal cities
Get all Eng, Sco, Wal cities

Non-functional Requirements:

The least work that will get the job done. First iteration may be a spreadsheet.

Current thinking is that documents (including this) and any code SHOULD use GitHub but it isn’t set up yet.

If there is any coding then it has to be in languages I want to learn: Python or LISP-family likely for back-end, maybe HTML5/CSS/JS for front-end.

Algorithms:

For each PopulationCentre to be shown, calculate the gravitational attraction to every other Population centre, as a vector and sum all the vectors. Represent this vector as an arrow on the map, scaled appropriately.

Initial calculation of gravitational force is to follow Newtonian physics.
Force (F) between 2 objects is proportional to the product of the masses of the objects m1 and m2 and inversely proportional to the square of the distance between their centres of gravity d

Other physics might be considered later, if we get an answer we don’t like; as usual.

Newton actually seems to have used ‘r’ rather than ‘d’ for distance but I think that is because he was interested in the radius of the orbit of planets around the sun, and much as London would like to think that is the case for the UK, I think birmingham.io has other ideas

Observation:
I’ve written far more than I’d have needed to if we were all standing around my white-board (and it was big enough for people to stand around.)


(Andy Wootton) #3

I started today. I gave up geography when I was 14 so I wasn’t expecting finding a reliable list of cities and their populations to be the hard part. It’s tempting but I don’t think I can put Birmingham as the biggest city with Leeds second. I need Greater London but I think Greater Manchester may distort the model unless I also use West Midlands.


(Steve Pitchford) #4

That looks like a lovely project. Have you considered using SVG / D3 for visualisation?


(Andy Wootton) #5

Yes to an SVG overlay but I haven’t got as far as ‘how’. I got bogged down while finding my preliminary data and did some “Don’t Involve Yourself” instead.

My first pass may be a spreadsheet, graph paper, ruler & protractor to check whether the result looks useful. I’m trying to learn to be quick and dirty in execution rather than over-planning it before I start.


(Andy Wootton) #6

With all the recent fuss about migration from Africa to Europe, I realised that the model could be extended to global migration. This gave me a new search term and I found http://en.m.wikipedia.org/wiki/Gravity_model_of_migration

The idea is sound (though “Opponents of the gravity model explain that it can not be confirmed scientifically, that it’s only based on observation” - like all science?) but I’m not the first to have had it. Oh well, at least I haven’t done 4 years of a PhD on it before finding it isn’t original.

I was also realising there were problems with ‘edge conditions’. I needed the coast and the country-side to act like dark matter in the gravitational model or there would be constant ‘inward’ forces. Some people are ‘attracted away from’ all cities or to the sea.


(Andy Wootton) #7

Cross posting ‘TV star’ Hannah Fry’s Python code


(Andy Wootton) #8

I’ve been reminded of this project by a Hannah Fry video. She even tells me what parameters I should have been considering https://www.youtube.com/watch?v=LnQYJa9-aR0


(Andy Wootton) #9

Having mentioned this project earlier I’ve been thinking about it again. I was considering how young people like to live in city centres but then want more space and gardens so commute to reduce prices and cities expand at the edges. I wonder if a valence/shell model from chemistry is appropriate, where at certain differential there is a sudden rush to an outer level.

I also thought about outward pressure as an alternative to gravity but it doesn’t work for jumps from city to city, unless people reach escape velocity from a place under pressure then get pulled in again by the gravitational field of another.


(Andy Wootton) #10

[Moved here from a relatively sane post.]

Brainstorm: Gravity can be modelled as a curved surface, can’t it, or flows of water with a gradient? Fluid flows, increasing entropy in the universe. An interesting contrast to the idea that people coming together in cities increases communication paths, leading to increased order in the information and greater wealth generation.

Model as pipes between cities; heights changing to cause flow in either direction. Electrical potential. ANALOGUE flows. On Silicon Canals the locks appear to flip between binary values but are discretely analogue.