Wednesday, March 22, 2006

Using the LineGeneralizer in FME to reduce the number of points in a Polygon

GTViewer and Pocket GTViewer both set an artificially low maximum number of points that can be used in certain elements. These element types include:
  • Line String Elements
  • Shape Elements
  • Shape With Holes Elements
  • Complex Line String Elements
  • Complex Shape Elements
  • Complex Shape With Holes Elements.
The maximum point count is kept low to force the use of smaller elements to improve display performance and to reduce the amount of memory resources required to render the element. Pocket GTViewer runs on devices with severely limited resources and strict attention must be paid to this hardware limitation if high performance is to be maintained on the handheld platforms. The desktop version of GTViewer is forced to comply with this low maximum too because one data set is desired for use between the desktop and the handheld platforms, plus what runs faster on the handheld will also run faster on the desktop.

Currently, the maximum number of points is set to 12,000 and is sometimes too low to accommodate certain elements. Some polygons may contain 50,000 or more points for seemingly trivial features. There are various ways to deal with this problem when converting data for GTViewer. The GTShapeConv utility can decompose one of these elements into a group of elements with fewer points and this is generally the ideal solution, but it becomes a problem when you do this with large polygons. The polygon element will be broken down into a group of independent line strings that together will look like the polygon. The problem with this solution is that the converted element is no longer a polygon and can’t be filled.

If you are using Safe Software’s FME to convert your data to the GTViewer format, a clever transformer called the LineGenerlizer can be used to thin out the number of points in a linestring or polygon. By simply placing this transformer between your source and destination and configuring its parameters, the number of points in the elements will be reduced and fit into the elements without breaking them up.

A variety of parameters are available to generalize the element. I will leave it up to the user to look at the FME documentation for more details. However, I will discuss how to determine if you have satisfactorily adjusted the parameters enough to get all of the large polygons small enough to fit in to the maximum allowed number of points. When you run FME to convert your data, you will get warning messages like the following for elements that contained more than the maximum allowed points:

Shape with Holes contains more than the maximum number of points (20094, Max: 12000). Converted as a group of linestrings.
Shape with Holes contains more than the maximum number of points (12374, Max: 12000). Converted as a group of linestrings.
Shape with Holes contains more than the maximum number of points (24081, Max: 12000). Converted as a group of linestrings.

For generalizations using the Douglas algorithm, you can increase the generalization tolerance until you no longer get these warnings.

Not only will this process reduce the number of points in the elements enough to generate the appropriate elements, the reduction in points further improves performance, reduces the overall data size, and you probably will not be able to tell the points were removed in the first place.

1 comment:

Larry Cosgrove said...

Hmmm. Why do I feel that his blog might somehow be related to me?