Files
Introduction
Normally, when writing to Google Earth KML files, FME users will write out locations as points. However, if you do not have location data but only addresses, you will need to use a geocoding service to generate latitude/longitude points.
Google Earth has a built-in geocoder that can be invoked by setting the kml_address format attribute on features with no location geometry. FME will write out the features with no geometry, and Google Earth will automatically create geometry using its geocoder upon reading the KML file. Its performance is somewhat slow, so it is not recommended for use with large datasets. For more information, see the Google Developers Guide.
Step-by-step Instructions
1. Add CSV Reader
Download the ADDRESS_POINTS.csv dataset from the files section of this article. Open FME Workbench, start a new workspace, and add a reader. Set the following parameters:
- Format: CSV (Comma Separated Value)
-
Dataset: ADDRESS_POINTS.csv
- Click on the ellipses to navigate to the location of the file on your computer
2. Create kml_address Attribute
Next, we will need to create the kml_address attribute, which will contain all of the address information. Add a StringConcatenator to the canvas and connect it to the CSV reader feature type. In the parameters, set the New Attribute to kml_address, then set up the following concatenation. Note for Constant, just leave it blank, and a space will automatically be added:
| String Type | String Value |
| Attribute Value | @Value(ADDRESS) |
| Constant | |
| Attribute Value | @Value(PRE_DIR) |
| Constant | |
| Attribute Value | @Value(STREET_NAM) |
| Constant | |
| Attribute Value | @Value(STREET_TYP) |
| Constant | |
| Attribute Value | @Value(CITY) |
| Constant | |
| Attribute Value | @Value(STATE) |
| Constant | |
| Attribute Value | @Value(ZIP_CODE) |
3. Style KML
If we were to write out the addresses now, it would be a mess of yellow pins and labels, so let's style the KML. Add a KMLStyler to the canvas and connect it to the StringConcatenator. In the parameters, expand the Icon section, then set the Icon Name to C1 and the Scale to 0.5. Next, expand the Line section and set the Line Width to 0. Finally, expand the Labels section and set the Scale to 0.
4. Write Out Data
Now we can write the data out. Add an OGC/Google KML writer to the canvas and browse to a location to save the dataset. Name the file Addresses.kml and then set the Feature Type Definition to Automatic.
In the Feature Type dialog, set the Feature Type Name to Address_Points, then click OK.
Connect the Address_Points writer feature type to the KMLStyler.
5. Run Workspace and View Output in Google Earth
Run the workspace and view the output in Google Earth. Depending on your internet connection, the address points may take a moment to load.
Data Attribution
The data used in this article originates from open data made available by the City of Austin, Texas. It contains data licensed under the Public Domain Dedication License, as provided by the City of Austin.