In this tutorial we will translate some Google Earth KML data, representing neighborhood
areas, to Esri shapefile.
Let's take a look at the Vancouverneighborhoods.kml file in Google Earth. We have area features
representing the neighborhoods and each neighborhood has a name along with population data. In
our FME workspace we are going to calculate the percent increase in population between
2001 and 2011. Here in the places window, make a note of the name of the folder, neighborhoods,
that contains the spatial and attribute details; we will work with this in the FME workspace.
In FME Workbench we will generate a workspace; select Google KML for the reader
and Vancouverneighborhoods.kml for the dataset. For the writer, select Esri shape. Also, select
a location to write the shape file to. FME scans the KML file and presents KML elements
as feature types. Remember, it's the neighborhoods element that contains the spatial and attribute
information, so we will only read that feature type.
There are two things to notice once the workspace is created; first, FME has automatically put
in a geometry filter transformer - this is because we are translating data from a format
that can handle multiple geometries per file to a format that only allows one geometry
per file so FME automatically separates the geometries for us. Remember, we are dealing
with just area features in our source dataset, so we can delete the outputs from the other
geometries that we don't need. Also notice that the attributes in the source dataset
are more than 10 characters long but, for shape files, the limit is 10 characters for
attribute names therefore FME has automatically truncated them. Let's rename these so that
they make a bit more sense.
Since we have renamed them we've lost the attribute mappings from the source so let's quickly connect them.
Expand the area output on the geometry filter then create the connections.
It's better practice to put these attribute mappings in a transformer; we can quickly do that by right clicking on the connection from the area output
port to the destination and selecting replace with attributerenamer.
The next step is to calculate the percent increase between 2001 and 2011 populations;
to do this we take the absolute value of the difference and divide it by the original value
- the resulting decimal is then converted to a percent. Let's put this formula into
an expression evaluator.
First we will give our new attribute a name, popchange, then we create the expression in
this window. You can double-click attributes over from the FME feature attributes list
and use the minus and divide keys to complete the expression. We will add some parentheses
around the whole expression and multiply by 100 to get a percent value.
One last thing, let's add our popchange attribute to our destination shapefile schema.
Its arrow is automatically green because we've named it exactly as we did in the expressionevaluator.
Run the workspace, right-click on the destination feature type and choose the inspect option.
The output shapefile opens in the FME Data Inspector and we see our new popchange value.