Tuesday, April 17, 2007

Using FME to report lines lengths per grid

I recently received a request from a reader asking me to give some more detail about how I accomplished the grid/valve KML report in "FME as a Spatial Intelligence tool for Smallworld". He wanted to do a slightly different report that summarized length of lines per grid.

Instead of explaining how I did that original report, I tried to see for myself if what he was asking was in itself an easy query in FME. I created a similar report using FME Workbench. You can see the FMW file here.

In less than an hour I was able to take as input Smallworld area and line features, and then compute the total length of all lines for a given area and then create both a CSV and KML report. CSV is a good and simple tabular report format. KML provides a nice visual representation that anyone using Google Earth can use to see your query results.

If you have FME Workbench, you can open the report_pipe_lengths_by_grid.fmw file and view the comments I put in there describing how the data/transformer flows work. If you do not have FME, you can download a fully functional trial version from http://www.safe.com.

The basic steps included:
  • read area and line feature sets from Smallworld into FME Workbench
  • use the LineOnAreaOverlayer transformer to split the line features at the area boundaries
  • use the LengthCalculator transformer to calculate the length of each line feature inside a given area boundary
  • use the Aggregator transformer to sum up the length of all lines per area feature
  • use the FeatureMerger transformer to assign the aggregate line length to each area feature
  • write results out to a KML file (click here for image of result)
  • write results out to a CSV file (click here for file)
The steps were fairly easy and demonstrate again the power of the FME tool for reporting and data manipulation applications.

[Shameless commercial plug: if you would like to explore how you could use FME to get meaningful reports out of your data, please contact me at the e-mail addresses listed on the "Contact Information" in the side bar of this blog]

1 comment:

Anonymous said...

Hi Alfred,
I like your goal of "Finding new and innovative uses for Safe Software's FME tool". It's the perfect software for innovating with I think. OK, I'm biased - I work at Safe - but I'm still finding new surprises on a daily basis.

I agree that FME is useful for reports like this. I worked with a customer recently who was impressed to find that not only could FME find holes and overlaps in his data, but that it would write out a report in CSV, with the feature IDs, the size of the overlap, and all sorted in order of overlap size.

The one suggestion I have is that you could replace the Aggregator with a StatisticsCalculator - that way you'd not just get overall length, but number of lines, mean length, max length, min length, SD, etc

If it's OK with you, I'll post a link to your blog on our FME user group, to show some of our other users the possibilities out there.

Mark Ireland, Safe Software.