FME Version
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 lat/long 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 a little slow, so it is not recommended anything other than small datasets. For more information, see the Google Developers Guide.
Step-by-step Instructions
1. Add CSV Reader
Open FME Workbench and start a new workspace. Add a Comma Separated Value (CSV) reader to the canvas and browse to the ADDRESS_POINTS.csv dataset which is available to download from the Files section on this article.
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 here originates from data made available by the Government of Austin, Texas. It contains information available to the public domain.
Comments
0 comments
Please sign in to leave a comment.