Converting Shapefile to KML


Shape2Earth for MapWindow GIS converts shapefiles into Keyhole Markup Language (KML) for viewing in Google Earth.

To convert a Shapefile to KML, first ensure that MapWindow GIS and Shape2Earth are loaded on your computer (installation instructions).

Open MapWindow, and either add a shapefile, or open a MapWindow project.  These examples use the 'United States' project file that is installed with MapWindow (C:\Program Files\MapWindow\Sample Projects\United States\United States.mwprj)


MapWindow with USA Project

KML Exporting

Shapefiles can be exported to KML using three methods.  There are three buttons on the toolbar for accessing these options.

KML Output Tools

Saving as a network link is useful if you want to keep exporting the shapefile using differerent options, and do not want Google Earth to zoom away from it's view everytime the KML file is reloaded.

Quick Example - Converting Point Data

Using the United States project (see Converting Shapefile to KML above), click on the USA Cities layer on the MapWindow Legend to select it.  Then, right click on USA Cities, and select Properties from the menu.

Overview of Google Earth

We are going to apply a theme to the data using it's attribute data.  On the Coloring Scheme Editor, click on the drop down box next to Field to color by, and select the value CAPITAL.  This will base the color of the city points by this value (is, or is not the State's capital).

Overview of Google Earth

On the Coloring Scheme Editor, click next to the lightening Bolt icon to vew your options for symbolizing the data.  MapWindow gives you three options.

  1. Single Symbol - This is the default if nothing is selected. A single symbol is applied to each feature.
  2. Continuous Ramp - Makes a smooth transition from one color to another based on an attrinbute value.
  3. Equal Breaks - Allows users to organize data into specific color categories based on thier attribute relationship
  4. Unique Values - Create a unique symbol for each unique value in the selected attribute field,

For this example, we will select "Unique Values" (see below).

Overview of Google Earth

After selecting Unique Values, we see that two values have been added.  Y for capital cities, and N for non-capital cities.  We can change the colors for these two data items by clicking on color in the Color Column to open the Color dialog box (below).

Overview of Google Earth

Keep clicking OK until all of the dialog boxes are closed, and we are back at the Legend Editor.  Now check the Point Size to make sure it is a good size for Google Earth (1 is good to start with --  see below)

Overview of Google Earth

Now, we are ready to create some KML.  Close the Legend Editor, and select Export to KML from the Shape2Earth menu (below).

Overview of Google Earth

On the Shape2Earth form below, we have changed the Layer Name from upper case CITIES to Cities, and have selected to have the Document open (the KML file will be expanded in Google Earth's Places tree).  We will not be using 3D options for this, but you are free to try it out..

Overview of Google Earth

Click on the Properties tab, and then click on the yellow pushpin icon next to the Style label.  You will get the Icon Selector form below.  Since we will be using the color codes created by MapWindow for the data, it is good to use a non-colored icon that will more easily show the MapWindow color.  We have selected the shaded_dot.png icon below.  Click OK when complete.

Overview of Google Earth

Click on the button next to Color to change the color of the labels for each point.  We have selected green below.

Overview of Google Earth

Click on Create Label Rollover to select the symbol that will appear when the user hovers the mouse over a point in Google Earth.  We have selected a different icon from the Icon Selector, increased the size of the point and label, and selected red for the labels color.  We have also selected Use Map Colors from the Point Options, so we will not change the color of the icon.

Overview of Google Earth

On the GIS Data tab, we have selected CITY_NAME as the Name Field, and we have selected STATE_NAME as the Folder Field.  This means that each point will be named by the city it represents, and grouped into the Folder with the name of the state it is in.

We have also selected Order by Feature Name and Order by Folders.  These options will sort the points alphabetically by their name, and will sort the Folders in the same manner.

In the Select Attributes to Write to KML box, we have checked the attribute fields whose data we would like to see in the Google Earth pop-up balloon for each point

Overview of Google Earth

On the Options tab, we have not changed the defaults.  All the data in the shapefile will be exported, and the Folders will be closed, but not locked (user will be able to expand the folder).

Overview of Google Earth

On the Balloon tab, we have selected Custom Balloon 1.  Balloons are defined in an XML file in the Shape2Earth directory, and can be manually modified or created using a text editor.  We have also changed the Organization Name to My Organization.

Once set, we can create our KML and load it into Google Earth by clicking on the Load In GE button.

Overview of Google Earth

Below is the resulting KML file in Google Earth.  Note that in the Places tree, a KML file named Cities is loaded with a Folder for every state that is closed.  The folders are in alphabetic order, as are the city points inside of them (Iowa folder opened for reference).  Also not that while all non-capital cities are green, capital cities (Des Moines) are red.

Overview of Google Earth

When the user hovers over a point (Des Moines below), the rollover style comes into effect.  Both the icon and the label have changed.

Overview of Google Earth

Below is the custom balloon that we have selected.  Balloon can be changed to meet the needs of your organization.:

Overview of Google Earth


Quick Example - Converting Line Data

UNDER CONSTRUCTION ..Export a Line:

Quick Example - Converting Polygon Data

UNDER CONSTRUCTION ..Export a Polygon Example

Selecting Features to Export

UNDER CONSTRUCTION ..Selecting Features to Export:

Updated on August 3, 2011