KML and KMZ Viewer: Read Google Earth Files in Your Browser

All tools
Report

Heading to the field? Install this site from your browser menu and this tool works with no signal. See how

KML and KMZ Viewer

Open a Google Earth file in your browser and read what is actually inside it. Nothing is uploaded. The file is parsed on your own device, so it works with no signal.

Drop a KML or KMZ file here or

Nothing leaves your device. Large files are fine.

No file to hand?

Waiting for a file.

Features in this file

NameTypeFolderVerticesLengthArea

Lengths use the Vincenty inverse solution on the WGS84 ellipsoid. Areas use spherical excess on the authalic sphere, which is what Google Earth reports. Holes inside a polygon are subtracted.

Two panels compared. The left panel opens a KML file to show the nesting of kml, Document, Folder and Placemark, with a Placemark holding one Point, LineString or Polygon geometry. The right panel opens a KMZ file to show a zip archive holding doc.kml alongside icon and overlay images. A band across the bottom states that KML writes coordinates as longitude first, then latitude, then height.
Notice that the KMZ is not a different format. It is the same XML with the images it needs, zipped together, which is why renaming it to .zip lets any unzip tool open it.

How to use this tool

Drag a KML or KMZ file onto the panel above, or press Choose a file. The file is read where it sits. Nothing is sent anywhere, so a 40 MB export of a whole survey opens as fast as your disk can hand it over, and the page keeps working on a laptop with no signal. If you have no file to hand, the two sample buttons load a small survey and a lease block so you can see what the output looks like.

The input people get wrong is the file itself. A KMZ downloaded from a phone or an email client is sometimes saved with the wrong extension, so a file called something.kml turns out to be a zip and a file called something.kmz turns out to be plain XML. This tool decides by looking at the name, so if you get a message saying the file is not a zip archive, rename it to .kml and open it again. The reverse case gives you a message about invalid XML.

Click any row in the feature table to highlight that feature on the map in red and show every attribute attached to it. That is usually the fastest way to answer the question you actually came with, which is where a particular placemark sits and what data someone stapled to it three years ago.

What the tool measures, and how

Length along a track is the sum of the geodesic distances between consecutive vertices, computed with the Vincenty inverse solution on the WGS84 ellipsoid. That matters more than it sounds. A simple flat calculation using degrees as if they were a grid is wrong by roughly the cosine of your latitude, which at 55 degrees north is an error of about 43 percent on any distance running east to west. Even the common improvement of treating the Earth as a sphere leaves you around 0.3 percent out, because the Earth is flattened at the poles by about one part in 298.

Area is computed by spherical excess on the authalic sphere, the sphere with the same surface area as the WGS84 ellipsoid, radius 6371007.181 m. Every closed ring contributes a term built from the change in longitude along each edge and the sines of the latitudes at its ends. Rings listed as inner boundaries are subtracted, so a lease block with a hole in it reports the net area rather than the gross.

This is deliberately the same method Google Earth uses to report area, so the number here should match what you see there. It is not the same as the area a projected GIS would give you, and the next section explains why that gap exists.

Why two tools give two different areas

Put the same polygon into this viewer and into a GIS project working in a national grid, and the two areas will differ slightly. Neither is broken. They are answering different questions.

A projected coordinate system flattens a curved surface onto a plane, and no projection can preserve area, angle and distance all at once. An equal area projection keeps area honest and distorts shape. A conformal projection, which is what most national grids are, keeps local angles and shape honest and distorts area, usually by a fraction of a percent that grows as you move away from the central meridian. Compute an area in a conformal grid and you get the area of the projected shape, not the area of the ground.

The spherical excess calculation skips the projection entirely and integrates over the curved surface directly, so it answers the question about the ground. For a small site the two agree to a few parts in ten thousand and the argument is academic. For a licence block spanning several degrees the difference becomes real money, and it is worth knowing which number your contract refers to before you argue about it.

There is a second, blunter reason for disagreement. If the KML was written by software that never set a projection properly, the coordinates in it may not be WGS84 at all, even though KML requires them to be. Nothing in the file format stops someone writing grid metres into a coordinates tag. If the map above puts your site in the sea off west Africa, that is what happened, and the fix is upstream in whatever exported the file.

A worked check you can repeat on paper

Press Load a sample lease block and follow along. Block 42 is a one degree cell with its corners at 0 and 1 degrees east and 45 and 46 degrees north, with a small square hole cut out of the middle. The spherical excess formula for the area of a ring is R squared over 2, multiplied by the absolute value of the sum over every edge of the change in longitude in radians, multiplied by 2 plus the sine of the latitude at each end of that edge.

Only the two edges that run east to west contribute anything, because the other two have no change in longitude and their terms vanish. Work along the outer ring:

  • Bottom edge, 0 to 1 degrees east at latitude 45. Change in longitude is 0.017453293 radians. The bracket is 2 plus sin 45 plus sin 45, which is 2 plus 0.707106781 twice, giving 3.414213562. The term is 0.059589268.
  • Top edge, 1 back to 0 degrees east at latitude 46. Change in longitude is minus 0.017453293 radians. The bracket is 2 plus sin 46 twice, which is 2 plus 0.719339800 twice, giving 3.438679601. The term is minus 0.060016281.
  • The two terms almost cancel. Their sum is minus 0.000427013, and the sign only tells you which way round the ring was drawn.

Multiply by R squared over 2, which is 2.029486625 times ten to the thirteen square metres, and the outer ring comes to 8666170166 square metres, or 8666.170 square kilometres. Run the same three lines for the hole, whose east to west edges are 0.2 degrees long at latitudes 45.4 and 45.6, and you get a sum of 0.000017081 and an area of 346651030 square metres, or 346.651 square kilometres.

Subtract the hole from the outer ring and you have 8319519135 square metres, which is 8319.519 square kilometres. That is exactly the total area card the tool shows, and you can see the same figure in the Area column of the feature table.

The near cancellation in that sum is worth noticing, because it is where precision goes to die. Two numbers around 0.06 differ in the fourth decimal place, so you lose roughly four significant figures the moment you subtract them. Doing this by hand with a five figure calculator would leave you with about one reliable digit. It is fine in double precision, and it is the reason a hand check of a small polygon can look badly wrong when the method is actually correct.

How this tool was checked

The engine was written twice. One implementation runs here in your browser, a second and independent one runs under Node with a different XML parser and a different unzip library, and the two are compared automatically on every change. Eighty four checks run across the pair.

The area routine is pinned to a case with an exact analytic answer. Take the triangle bounded by the equator from 0 to 90 degrees east and the two meridians running up to the north pole. That is one eighth of the sphere, so its area must be pi times R squared over 2, and the code returns that to the last bit a double can hold. The hemisphere returns 2 pi R squared on the same test. A second and completely different area route, projecting to Lambert azimuthal equal area and then applying the shoelace formula, agrees with the spherical excess route to 0.0043 percent on the sample lease block, which is the small penalty you pay for treating the projected edges as straight lines.

Distances are checked against published WGS84 values: 10018754.171 m for a quarter of the equator, 10001965.729 m from the equator to the pole along a meridian, and 110574.389 m for one degree of latitude at the equator. All agree to within four parts in ten million. As a sanity check on real ground, the graticule box that Colorado is built from comes out at 268994 square kilometres against a published 269601, a difference of 0.23 percent that is explained by the state boundary not following the parallels exactly.

One difference is worth reporting rather than hiding. A 200 m hop computed in Chrome and in Node differs by about 0.35 nanometres. The specification for JavaScript does not require sine, cosine and arctangent to be correctly rounded, so different engines can differ in the last bit or two. Running the browser code inside Node reproduces the reference exactly, which confirms the gap is arithmetic noise rather than a difference in method.

Mistakes that catch people out

Longitude comes first. KML writes each coordinate as longitude, then latitude, then height, which is the opposite of how most people say it out loud and the opposite of what a GPS screen shows. Swap them and a site in Colorado at 37 north, 109 west lands at 37 west, 109 north, which is in the Arctic Ocean. If everything in your file has moved somewhere absurd, check this first.

A KMZ is a zip, so it cannot be edited as text. People open one in a text editor, see binary rubbish, and conclude the file is corrupt. Rename it to .zip, extract it, and the doc.kml inside is ordinary XML you can edit freely. Zip it back up afterwards and rename it again.

Only one geometry per placemark, unless you use MultiGeometry. A placemark carrying a point and a track has to wrap both in a MultiGeometry element. Plenty of software reads only the first geometry it finds and silently discards the rest, which is how a file that looks complete in one program arrives half empty in another. This viewer reads the direct child of the placemark, so the whole MultiGeometry survives, and the sample lease block includes one so you can confirm it.

Height is not elevation above ground by default. The third number in a coordinate is measured from the WGS84 ellipsoid unless the placemark carries an altitudeMode saying otherwise, and the ellipsoid can sit tens of metres away from mean sea level. If you are pulling heights out of a KML for anything that matters, find out what the exporting software meant by them before you use them.

Folders are not just decoration. A placemark inherits meaning from the folder it sits in, and two features with the same name in different folders are usually different things. The folder column in the table above shows the full path so you can tell them apart, which matters most in files where every point is called Waypoint.

Related Calculators and Reference

Once you have the coordinates out of a KML, the next step is usually to put them into a grid you can set out from, or to turn a scatter of points into a surface.