If you have some data in table format with IDs for fields or point locations on the map and Google Earth KML file with those fields having same IDs, it is generally possible to bring spatial information to Excel and merge those data sources together to use in further spatial analysis in other GIS software and in newly released FREE ESRI Maps for MS Office Beta 2. There are a few little tricks to it, though…
Google Earth KML files are essentially XML files with geographical information, but Excel will not open them directly.
If you click Yes, Excel will recognize the file as XML, but will fail to import it nevertheless.
So, you will need to re-name the KML file so it has XML extension. Right click the KML file and select “Open with” Notepad:
It will show XML formatted text in Notepad.
Go to File/Save As and select “all files” option.
then type NEWFILENAME.xml together with extension
Open a new MS Excel file (or the file with your tabulated data information you want to bring KML location data in). In File tab, hit Open and open the NEWFILENAME.xml file. It will recognize it as XML table and suggest schema. Agree to everything! If all goes well you should see the table with all your data similar to
If your data had polygons, each field will have two lines, sort by coordinates column and erase empty lines. You will end up with a table like this:
Notice, that both Latitude and Longitude in in the same column, separated by comma. In Excel 2010 you can separate those rather easily. Insert empty column to the right of the merged coordinates column. Highlight the coordinates column, go to Data tab and click Text To Columns, pick Delimited, and Separated by Comma.
Now you have it – two separate columns with exact geographical coordinates in Decimal Degrees, to merge with your other data in Excel. Name them X-Longitude and Y-Latitude (remember, in western hemisphere, Longitude is negative!)
Converting KMZ file to KML
The procedure described above will not work on KMZ files directly. When you open KMZ (zipped KML file) in Notepad, you will not see XML formatted text as in example above, but some gabled code like:
To convert KMZ to KML you will need Google Earth installed. Bring KMZ to the map, right click on the layer you want to convert and select “Save Place As”
“Save as KML” from drop down list. This will generally blow up the file size about 3 times. To bring those Coordinates to Excel, follow the instructions above for KML file.
Troubleshooting
If import fails read the Log info, for me it has happened when field names had spaces, like "11Z365 D"… Thanks to readers of this blog (Michael Bruening) there is a solution how to get rid of spaces in Excel: you could always select the column/row within the excel spreadsheet and do a “Find and Replace” of a [space] with an [underscore].
If you have ESRI ArcMap installed, you can go to Toolbox\Conversion Tools\From KML to Layer
Then go to Point Table, add XY coordinates to Centroids (procedure in previous post), and finally export that table to Excel.
If you need futher assistance with your KML data, please, do not hesitate to contact Landviser, LLC - post comment, email info@landviser.com, or call 609-412-0555.