Files
-
- 60 KB
- Download
Introduction
This tutorial will show you how to convert an Esri shapefile (*.shp) to a Google KML (*.kml). We will transform the City of Vancouver postal code data from an Esri shapefile, style the data using a different color, and export the data 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.
Now, to view the data, click on the ForwardSortationAreas reader feature type on the canvas to open the pop-up menu. Then, on the mini toolbar, click the View Source Data button to view the data in the Visual Preview Window.
We have area features representing the forward sortation areas. There is a single attribute (CFSAUID) that identifies the forward sortation area, which is the first three characters of the Postal Code.
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.
3. Set KML Properties
When viewing a KML file in Google Earth, clicking on a feature displays an information bubble. 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 KMLPropertySetter 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.
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.
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.
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 mini toolbar. Then, click the Open Containing Folder button and double-click the VancouverFSA.kml file to open it in Google Earth.
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.
Data Attribution
The Forward Sortation Areas data set provided here is sourced from Statistics Canada's 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.