How to convert Esri Shapefile to KML

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

  • FME 2019.x

Introduction

This tutorial will show you how to convert Esri shapefile (*.shp) to Google KML (*.kml). We will be transforming City of Vancouver postal code data from an Esri shapefile, styling the data using a different color, and writing the data out into a Google KML format.

The Esri shapefile (forwardsortationareas.shp) denotes the different postal districts covering Vancouver. A forward sortation area (FSA) is a geographical region in which all postal codes start with the same three characters. The first letter of an FSA code denotes a particular "Postal District".

 

Video

This video was created with FME version 2016.0. Some of the steps might be slightly different, but the overall process is the same for newer versions of FME.

 

Step-By-Step Instructions

1. Inspect the Data in FME

The first step is to inspect the ForwardSortationAreas.shp file. Open a blank FME Workspace and add a new reader. In the reader dialog, type in Esri Shapefile, then browse to the ForwardSortationAreas.shp file. Click OK to add the reader to the canvas.

reader.png

 

Now to view the data, click on the ForwardSortationAreas reader feature type on the canvas to open the popup menu. Then on the popup menu click the View Source Data button to view the data in the Visual Preview Window.

popupmenu.png

 

We have area features representing the forward sortation areas. There is a single attribute (CFSAUID) which identifies the forward sortation area, which is the first three characters of the Postal Code.

visualpreview.png

 

Note: This step can also be completed in FME Data Inspector for versions previous to FME 2019. Just be sure to add the Esri shapefile reader to FME Workbench after inspecting the data.

 

2. Set the Output (Writer) Format to Google KML

Next, we need to add a writer to the canvas. Click on the Add Writer and in the Add Writer dialog box, for the Format, select Google KML.

Then for Dataset, browse to a folder to save the KML file and then set the filename to VancouverFSA.kml, click OK to add the writer.

writer.png

 

3. Set KML Properties

When viewing a KML file in Google Earth, if you click on the feature, an information bubble appears, we want to set what is displayed in the bubble. Add a KMLPropertySetter transformer to the canvas and connect it to the ForwardSortationAreas reader feature type. In the KMLProperySetter parameters, set Name to CFAUID and then set Include Attribute Table to No. If we had other attributes, we would leave this set to Yes.

kmlpropertysetter.png

 

4. Add a KMLStyler

Before writing the data out, we need to style the KML file otherwise it will just appear as a white polygon. Add a KMLStyler transformer to the canvas and connect it to the KMLPropertySetter output port and then connect it to the Google KML writer feature type.

workflow.png

 

Then in the parameters, set the Color and Fill color to any color you choose, in this example we have used purple. If you were working with point data, you could set the icon type in this transformer.

kmlstyler.png

 

5. Run the Workspace

Then run the workspace by clicking on the green play button.

 

6. View the Output Dataset in Google Earth

To view the output dataset, click on the ForwardSortationAreas writer feature type to open the popup menu. Then click on the Open Containing Folder button, then double-click on the VancouverFSA.kml file to open it in Google Earth.

openfolder.png

 

If you do not have Google Earth installed, you can still view the data in FME, you won’t be able to view the contents of the information bubble.

googleearth.png

 

Data Attribution

The Forward Sortation Areas data set provided here comes from Statistics Canada, 2011 Census Digital Boundary Files, 2013. Reproduced and distributed on an "as is" basis with the permission of Statistics Canada. © This data includes information copied with permission from Canada Post Corporation.

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.