3. Objective of
Exercise
-Create simple process
to display photos in
Google Earth and
produce a complete
KMZ file for distribution
-Enhance process to
label photo points,
organize different types
of photos into folders
and use different icons
to represent each type
Our organization purchased its first FME Professional license in March of 2000.
By October of that year our use of the product had grown so much that we converted our one fixed license to two floating licenses
We have continued to use it since and in 2014 we converted our two floating FME Professional licenses to FME for ESRI licenses so that we could write data to enterprise geodatabases
We use the FME to convert data between different formats and often do complex processing of data during this conversion.
The idea was to create a workbench process that used just a few transformers to read geotagged photos (I used ones produced with my cell phone with its built in GPS) and create a KML file that would be used in Google Earth to display the photos as points and display the photos when the points are clicked. Then a KMZ file could be produced from Google Earth with the photos embedded for easy distribution.
The entire process would be run in three steps:
Run workbench process to produce KML file
Open KML file in Google Earth
Save KMZ file from Google Earth
<CLICK>
Next the workbench process would be enhanced with just a few more transformers and a minimal amount of extra work to add to custom icons, point labels and the photo points organized into different types of features to the KML file
So the basic workbench process was accomplished with just three transformers, with the help of a complex transformer JpegGPSPointReplacer that was obtained from the FME Store
First the process was generated with the wizard selecting the input data as a jpeg reader and the output as a KML file reader
<click>
Next the input data fme_dataset attribute is exposed so that the photo filename can be accessed
<click>
Next a StringSearcher transformer is added to parse the fme_dataset name into three parts with the third part being the file name of the photo. A regular expression is used to separate the complete filename and path into the parts. The different parts are put into the Filename_parts with the name of the photo in the third part
<click>
Next the JpegGPSPointReplacer transformer is added from the FME Store. This transformer obtains the GPS coordinates from the photos EXIF file header and turns the input photo feature into a point for the KML file
<click>
The third and last transformer to set the key properties in the KML file is added next. Here in its properties you can see the Name attribute is set to the photo file name (which is obtained from the parsed string created by the first transformer), this name will appear beside the photo point in Google Earth. The filename of the photo is included as an additional file and it’s path is left blank since it is in the same folder as the KML file. The content for the balloon that appears when the point is clicked on is set to HTML and its content can be set by clicking on the button beside its box
<click>
In the HTML content you can see that we are referencing the photo filename as the source for the image. An HTML div element is used to contain the image
<click>
Next the feature name is set in the output KML file so that the main document will have a meaningful name
<click>
Finally the workspace is run, all of the JPEG files to be put into the KML file are selected as the input JPEG files and the output KML file is named to be in same folder as the JPEG files
Here you can see the output KML file in the same folder as the photos, it is necessary for it to be in this location. Next you can double-click on this file to open it in Google Earth
Here is the KML file opened in Google Earth. The generic icons are used to mark the points and the photo filenames are used to label them, these filenames were assigned to the Name attribute in the KML properties transformer in the previous slide
<clic
Next the marker on Garbage Hill is clicked and the photo taken at that point is displayed
<click>
To finish you right click on the document to save the file as a KMZ file and to package the photos with the KML file
<click>
Here you can see the dialog to save the KMZ file
Here you can see the large KMZ file that was produced with the photos embedded in it. This file can be distributed as a complete file
Here I have created a CSV (comma separated value) file with a header row identifying the columns and:
The first column contains the filename of the photo to use in joins with the feature
The next column contains the neighbourhood that the photo was taken in
The next column contains a descriptive name for the photo to use as a label in the Google Earth file
The next column contains the category of the photo to use in grouping the photo in the table of contents in Google Earth
The next column contains the name and location of the icon graphic to use in marking the photo on the map
The last column has the size to display the icon at in the Google Earth file
A published parameter will now be added to allow the dynamic selection of the photo attributes CSV file. The CSV file will be used in the Joiner transformer to connect the photo attributes to the input photos
<click>
Right-click on the published parameters section to get to the menu item to add a parameter
<click>
Select a parameter type of existing filename, enter a name and a prompt for the parameter and set a file filter of *.csv for the file type
<click>
Next is displayed the final parameter definition, I left the default value field blank
<click>
Here is the parameter in the list of published parameters, I moved it up to the second position
Now the basic workbench file is modified to allow for improved symbolization of the photo points using information from the photo attributes CSV file
Here is the workbench file with room for two new transformers
<click>
Next the Joiner transformer is added with the CSV file parameter selected as the reader file and the table file (here I experienced a gotcha where I had left the default value for this parameter blank, I had to go back and fill it in so that when I selected the fields to add the process could read values from a file. I selected the filename parsed from the full filename as the point field to join to the filename field from the CSV file. Then I selected the Category, IconFileName, IconSize, and PhotoName fields to be added from the CSV file
<click>
Next the KML Styler transformer is added to set the icon to the IconFileName and the icon size to the IconSize values read from the CSV file
<click>
Next the KML Property Setter transformer is changed to set the name of the item to the PhotoName read from the CSV file to improve labeling of the points
<click>
Next the feature type name in the output KML file is changed to the category for the photo that was read from the CSV file in order to group the photos in the output KML file into categories
<click>
The enhanced process is now run to produce a better KML file, you now see that there is a third parameter, this is the user selectable CSV file of photo attributes
Here is the enhanced KML file with photo points labeled with descriptive names and icons used to mark different types of photos and the table of contents on the left with photos grouped into different categories. One of Winnipeg’s finest coffee shops is shown here
<click>
Here is a view of a sunrise (from my back yard) in Google Earth