Converting CSV Data to KML and SHP using Excel and ExpertGPS

Arvind asks:
quoteI have whole bunch of files in csv (or excel) similar to the one attached. How can I create KML or SHP files from here. Once imported to EXPERT GPS, can I add/edit attributes?quote

The finished map of CSV data over an aerial photo
Route start and end points with latitude and longitude in Excel spreadsheet

This is an advanced tutorial, showing several strategies you can use to manipulate just about any data in Excel or your favorite spreadsheet program (I use the free OpenOffice Calc) to get it into a standard format that ExpertGPS can import, map, and convert to KML, SHP, and/or DXF.

ExpertGPS can import CSV and text data directly – just copy and paste into either the Waypoint List or the Track List. However, the data in the file above is in a strange format – each line contains two latitude/longitude coordinate pairs – a starting point and and ending point. Each line is its own two-point line segment, and when plotted all together, they define a complete route.

Whenever I see multiple coordinates on the same line, I stop thinking about the CSV import function in ExpertGPS (which expects a single point per line) and instead start thinking about Google Earth’s KML format. Basically, my strategy is to use the formulae in Excel to build up a KML file which I can then paste right into ExpertGPS.

A Bare-Bones KML File

<?xml version="1.0" encoding="UTF-8"?><kml xmlns=""><Document>

<Placemark><LineString><coordinates>-104.57638956,39.70689113 -104.56884853,39.71147660 -104.56015453,39.70639827 </coordinates></LineString></Placemark>


Above is a very basic KML file, just a line with three points. Let’s call the first line the KML Header and the third line the KML Footer. The line in the middle is what we want to create in Excel – one of these for each row in the CSV file.

I used the Text to Columns command (on the Data menu in OpenOffice Calc and Excel) to split the coordinates out into four new columns, as seen above. Then I used the CONCATENATE function in Excel to build up a KML LineString Placemark for each row. IMPORTANT: KML puts longitude before latitude!

Using Concatenate in Excel to construct KML from CSV data

I added the KML Header to the very first line of the new column, and added the KML Footer at the bottom row.

Finished KML in Excel

Now I just select the entire column, copy, and paste into the map in ExpertGPS. It worked – all of the data from Excel matches up perfectly with the color aerial photos underneath. From here, I can export to ESRI SHP, to AutoCAD DXF, or edit the created tracks in ExpertGPS to add attributes prior to saving in GPX or KML format.

Need help converting a GPS, GIS, or CAD file?

The article above should give you some ideas of how you can use ExpertGPS and your spreadsheet software to convert just about any delimited text data to another GIS, CAD, or GPS format. The ExpertGPS Blog contains lots of tutorials on these sorts of conversions (most are MUCH easier than this, once you’ve downloaded a trial copy of ExpertGPS!). If you still need help, contact me using the Ask the GPS Expert link above – I’m always happy to help.