Google Earth Blog

Making KML files smaller by reducing precision

Our KML map of 3D areas has been steadily growing in size as new areas are added. We have considered converting it to KMZ format, which is the compressed version of KML files. KMZ uses standard ZIP compression and in many cases provides significant compression ratios. In our case it would shrink our KML file by over 60%. We have held back because this would mean changing the link to the file and as most users access it via a network linked KML we would also have to notify them to re-download the original KML with a new link. There are workarounds to this problem, so it might be worth doing. The other downside is that it adds an extra step to the process of updating the file as we would have to convert it to a KMZ file before uploading it.

Because of the above complications we have been giving some thought to other methods of making the file smaller. One thing we have noticed is that Google Earth saves KML files with an unnecessary amount of precision for latitudes and longitudes. It typically saves latitudes and longitudes using 16 significant digits. If you configure Google Earth to use decimal degrees then edit a placemark in Google Earth, it only actually shows 5 decimal places.

So how many decimal places are actually needed? We calculated that rounding to five decimal places results in a maximum error of just under a metre. Rounding to six decimal places gives an error of less than 10 centimetres. 14 decimal places gives an accuracy of less than a nanometre. Given that most Google Earth data such as altitude data or even image alignment can be off by many metres, having nanometre resolution in your KMLs is just wasting space. For our KML file five decimal places should be more than enough.

As you can see below, the results were quite impressive. Simply discarding unnecessary decimal places reduces the file size by almost half. We also show the effects of using the KMZ format.

We thought that other people with large KML files might find the idea useful. So, below is a JavaScript tool that will take a KML file and reduce the precision of the latitudes and longitudes.

Notes:

Precision: (decimal places)

 

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.

Exit mobile version