Powers of ten: a Google Earth demo

This project was started by a friend of mine Richard Treves who had worked before on recreating part of the excellent 1977 video by Charles and Ray Eames on the effect on our perception of scale of increasing orders of magnitude.

Richard wanted to take the original demo which was centred on a park in Chicago where the original film was based and make it so that you can centre the demo where ever you happen to be, or in fact for geocoordinates anywhere on the planet.

You can have a go here to see how it works.

Powers of ten

Choose a location to start powers of ten demo.



Richard has talked on his blog a bit about what you can do with the demo and why it was made, so I will talk about about how it was made.

I decided to keep the actual coding pretty simple. I used Javascript with the browser to geolocate the user, and a simple PHP5 script to build the Google Earth data file (KML file) for that location.

Google Earth uses geocoordinates given by a latitude and a longitude in degrees to describe a position on the surface of the Earth. This combined with a hight above the surface of the Earth describes a point in 3 dimensional space.

To make the scales meaningful the power of ten squares (1 m², 100 m², etc) had to lie on a plane that met the surface of the Earth to form a tangent at the point on the surface of the Earth described by the given geocoordinates.

It was not immediately obvious to me how I was going to describe the position of the corners of the squares which would increasingly lie further away from the curvature of the Earth as the scales increased and so have a decreasing relationship to the distance between any two points on the surface.

To complicate matters a bit the Earth, in both reality and as modelled in Google Earth is not spherical but forms an oblate spheroid. Where the major axis (equatorial diameter, approx. 12,756 km) is slightly greater than the minor axis (polar diameter, approx. 12714 km).

I considered trying to adapt Vincenty’s formulae to my problem, but quickly decided that the difficulty of doing so much outweighed the benefit in terms of accuracy. The differences between the major axis and minor axis of the Earth is not great and the difference can be mitigated by using the mean radius of the oblate spheroid approximation when using a spherical approximation.

Even with this simplification the problem of describing points on a plane in terms of a latitude, longitude and height above the surface of the earth was not an easy problem. However I realised that describing the position of the corners of the squares laying on plane tangential to the surface of the Earth was easy if I described them in euclidean space, with an (x,y,z) coordinate describing their positions on a set of X, Y and Z axes.

Taking the sphere approximating the Earth to have its centre at the origin with north aligned with the positive Z axis, a plane tangential to the surface of the Earth can then easily be describe as being x=r where r is the radius of the sphere.

So the 10 meter by 10 meter square can be described as having a bottom left corner at (r,-5,-5) and a top right corner of (r,5,5).

Once I had described all the points I needed for the different size squares I could apply a rotation matrix to the points. A rotation matrix rotates a point in euclidean space about the origin without increasing its distance from the origin. In other words the plane would still form a tangent with the surface of the sphere describing the Earth after being rotated by the number of degrees.

R_y(\phi)=\left[ {\begin{array}{ccc}                    \cos \phi & 0 & -\sin \phi\\                    0 & 1 & 0\\                    \sin \phi & 0 & \cos \phi\\                  \end{array} } \right]
R_z(\lambda)=\left[ {\begin{array}{ccc}                    \cos \lambda & -\sin \lambda & 0\\                    \sin \lambda & \cos \lambda & 0\\                    0 & 0 & 1\\                  \end{array} } \right]

Having moved all my points so that they are centred on the geocoordinate I want, all I had to do was convert each of them from euclidean space to geocoordinates and subtract the mean radius of the Earth (r) from the distance from the origin (ρ) to give me the height above the surface of the Earth for my point (h).

\rho=\sqrt{x^2 + y^2 + z^2}
\phi=\frac{\pi}{2} - \arccos \frac{z}{\rho}
\lambda=\arctan \frac{y}{x}
h=\rho - r

This gives me my latitude (φ), longitude (λ) and my height (h) for each point, which gave me everything I needed to build a KML document to do what we wanted.

It was an interesting little project, and hopefully will provide some education for others as it did for me. Thanks again to Richard for giving me this interesting project to work on.

Leave a Reply