Thursday, November 10, 2005

Tips on using the GTShapeConv Utility

There are several approaches for converting Shapefiles to GTI's GTViewer format. Safe Software’s FME can be used, the GTData utility GTShapeConv can be used, and soon GTViewer will be able to import shapefiles directly (to match its direct shapefile export functionality). This posting contains a brief review of some of the commonly used items with GTShapeConv that may not be obvious from the documentation.

GTShapeConv is one of the many utilities provided with GTData. This particular utility is a command-line tool that accepts a parameter file as input. The parameter file contains a section for each shapefile you will be converting and can include multiple sections that use the same shapefile only with different filters and/or symbology settings.

There are 2 types of sections in the parameter file: Main and Category. The main section is the [GTShapeConv] section and is always first. This section contains the coordinate factor conversion entries and any global entries. A global entry is a default value that will be used by the category section; so instead of repeating an entry with the same value in each category section, the global entry can be defined once in the main section and will be the default if the entry is not defined in a category section.

The category section will create a GTViewer category (.gtg file) from a specified shapefile. It is important to recognize a few characteristics of the category section when defining your GTViewer categories. A category section is specified with [Category #] where # is the category number. A category number can be used more than once in the parameter file. All of the data converted for these sections with a common category id will be added to the same .GTG file. This ability allows multiple shapefiles to be merged into one GTViewer category.

A category section also supports a FilterValue entry as well as an OmitValue entry. The FilterValue entry specifies a criteria for elements that you want to keep and the OmitValue specifies a criteria for elements that you want to omit. These entries are repeatable and both specify an attribute name and a value. By keeping or omitting specific elements in the shapefile, you can split a shapefile into multiple categories or change characteristics of elements within a single category by changing the symbology or filter id of the converted elements related to that section. The FilterValue and OmitValue also have a special mode where you can use a wildcard to perform begins with, contains, or ends with matches. The OrFlag entry is also available to allow multiple FixedValues to be ORed instead of ANDed together when specifying multiple entries all using the same attribute.

In the past, most shapefile parameter files specified all of the symbology used by the converted elements. Now, with GTViewer’s Style Manager, it is much easier and more flexible to just assign all of the different style groups a particular Filter Id and use the Style Manager to define the styles. You may also prefer defining some of the symbology in the parameter file and the rest with the style manager.

The HoleFlag entry is an item that should be set for each conversion (probably as a global entry). The entry can be set to 3 values:
  • 0 – use original method of shape elements and linestrings (default).
  • 1 – use Shape with Holes elements for all Shape elements in Shapefile.
  • 2 – use Shape with Holes elements only for Shape elements with more than one part.

The default is unfortunately the worst option to use, but support for Shape with Hole elements was not available in early versions of GTViewer, so 0 has remained the default to assure backward compatibility. Mode 1 can be used which converts all polygon type elements as Shape With Hole Elements; however, Mode 2 is probably the best choice because it will use the simpler Shape element when a polygon only has one part (and no internal holes or disconnected parts). Mode 2 will also reduce the size of the converted file if there are many elements than can be simple Shape elements and a Shape element is more performant than a Shape with Hole element (especially with Pocket GTViewer).

The TableNum and KeyAttribute entries define the linkage between the graphic and tabular data. The TableNum value will become Key1 on the element and the KeyAttribute will become Key2 on the element. TableNum is a number, but KeyAttribute can either be an attribute from the data or which uses the row id of the record.

While there are alternative now to using GTShapeConv, it will always remain an important part of GTData because of its speed, flexibility, and ease of use.

No comments: