In our recent post about LIGO and other large scientific instruments we mentioned that the Large Hadron Collider (LHC) at CERN in Geneva, Switzerland is underground. We know that it is circular and we were able to identify several buildings on its circumference. We would have liked to use that to draw a circle showing the location of the LHC. However, Google Earth does not have an option to draw circles. There are a number of tools on the web that will create a circle, given the coordinates of the centre and a radius, but in this case we don’t know where the centre is.

So, we thought it might be useful to have a tool that can draw a circle, given any three points on its circumference. It turned out to be more difficult than we expected, as trigonometry on the surface of the Earth is quite complicated. In two dimensions, the basic concept is easy; you just draw a triangle based on the three points, bisect the lines and where they intersect should be the centre. We used the same process but each of the steps has to be carried out using rather complicated formulas because of the curvature of the Earth. We used two different JavaScript libraries as we needed functionality from both. For distances and bearings we used GeographicLib, which is a popular open source library for geographic calculations. However, the current JavaScript version of GeographicLib does not include a method of finding the intersection of two geodesics so for that we used Geodesy from Movable-Type.

The results are not very accurate so if anyone knows a better algorithm for finding the centre of a circle on the surface of the Earth please let us know in the comments.

To create a circle simply create a KML file with three placemarks, upload it below and click ‘Create Circle’.

Show calculations.

To create a circle that you know the centre of, create a placemark at the centre and name it ‘centre’ and create a second placemark on the circumference. Then upload it above and click ‘create circle’.

### About Timothy Whitehead

Timothy has been using Google Earth since 2004 when it was still called Keyhole before it was renamed Google Earth in 2005 and has been a huge fan ever since. He is a programmer working for Red Wing Aerobatx and lives in Cape Town, South Africa.

DJ says

Wow… tried this with the kml at this link https://dl.dropboxusercontent.com/u/567495/Temp/circle%20test.kml and it did correctly generate the triangles and bisect them BUT the circles that were created did circumferential loops around the earth several times such that I couldn’t tell what it was doing.

DJ says

Actually, the thought occurs to me that you may want the kml file that your program created too – it’s here https://dl.dropboxusercontent.com/u/567495/Temp/Circle.kml

Interested to know what happened – sure would like to see your code for doing this.

Timothy Whitehead says

It does look interesting. It appears to have found the intersection of the lines on the far side of the earth and then drawn a large circle around that. I’ll have to find away to avoid that. I’ll also add a link to the code once I have it fixed.

Charlie Bader says

Google Earth Pro does circles with the measure tool. You could do a successive approximation where you draw the circle, move the center, change the radius until you get coincidence.