Reader Directives
The suffixes shown are prefixed by the current <ReaderKeyword> in a mapping file. By default, the <ReaderKeyword> for the Shapefile reader is SHAPE.
DATASET
Required/Optional: Required
The value for this directive is the folder containing the shapefiles to be read, or a single Shapefile. A typical mapping file fragment specifying an input Shape dataset looks like:
SHAPE_DATASET /usr/data/shape/92i080
Workbench Parameter: Source Esri Shapefile(s)
DEF
Required/Optional
Optional
The definition specifies only the base name of the file, the type of geometry it contains, and names and types of all attributes. The syntax of a Shape DEF line is:
<ReaderKeyword>_DEF <baseName> \
SHAPE_GEOMETRY shape_point| \
shape_multipoint| \
shape_polyline| \
shape_polygon| \
shape_null| \
shape_multipatch| \
[<attrName> <attrType>]+
Note: In older versions of FME, shape_polyline was called shape_arc. This has been changed to avoid confusion with mathematical arcs. However, FME still accepts shape_arc in place of shape_polyline to accommodate backwards compatibility.
Shapefiles with geometry of shape_point, shape_multi_point, shape_polyline, and shape_polygon contain two-dimensional features. If the type of geometry has an m at the end, then each two-dimensional coordinate of a feature may optionally have an associated measure value. If the type of geometry has a z at the end or is shape_multipatch, the shapefile contains three-dimensional features, and each coordinate may optionally have an associated measure value.
The file name of the each of the physical shapefiles is constructed by adding their extension to the base name. The SHAPE_GEOMETRY clause specifies the geometry type for the entire file.
Tip: When creating shapefiles, no attributes need to be specified on the ESRISHAPE_DEF line. When no attributes are defined on a shapefile being written, FME automatically generates an _ID attribute for the shapefile. This is useful if the shapefile is to be imported into ArcInfo. If the shapefile contained polygons, an AREA attribute is also generated. In both cases, the values of these attributes will be missing for all features.
Shapefiles require at least one attribute be defined. The attribute definition given must match the definition of the file being read. If it does not, translation is halted and the true definition of the shapefile’s attributes is logged to the log file. All shapefile attribute names must be uppercase and must not exceed 10 characters in length. The following table shows the attribute types that are supported.
Field Type | Description |
char(<width>) |
Character fields store fixed-length strings. The width parameter controls the maximum characters that can be stored by the field. When a character field is written, it is right-padded with spaces, or truncated, to fit the width. When a character field is retrieved, any padding space characters are stripped away. |
date |
Date fields store dates as character strings with the format YYYYMMDD. |
logical |
Logical fields store TRUE/FALSE data. Data read to or written from such fields must always have a value of either true or false. |
number(<width>,<decimals>) |
Number fields store single and double precision floating point values. The width parameter is the total number of characters allocated to the field, including the decimal point. The decimals parameter controls the precision of the data and is the number of digits to the right of the decimal. Additional digits will be rounded off. |
The following mapping file fragment defines two shapefiles: one containing polygonal features possibly disjoint and with holes, and the other containing linear features:
ESRISHAPE_DEF landcover SHAPE_GEOMETRY shape_polygon \ AREA number(12,3) \ TYPE char(11)\ PERIMETER number(12,3) ESRISHAPE_DEF roads SHAPE_GEOMETRY shape_arc \ NUMOFLANES number(2,0) \ TYPE char(5) \ UNDERCNST logical \ DIVIDED logical \ TRVLDIR char(6)
IDs
Required/Optional
Optional
This optional specification is used to limit the available and defined shapefiles read. If no IDs are specified, then all defined and available shapefiles are read. If more shapefiles were in the folder, they are ignored. The syntax of the IDs directive is:
<ReaderKeyword>_IDs <baseName1>\
<baseName2> …\
<baseNameN>
The base names must match those used in DEF lines.
The example below selects only the roads Shapefile for input during a translation:
SHAPE_IDs roads
Workbench Parameter
Feature Types to Read
MEASURES_AS_Z
This Navigator parameter controls how measure data associated with geometric data is treated. The default is No, which preserves the measures on the features. If Yes, measure data is treated as elevation values, and the existing z values are overwritten with the measure values, if they exist.
Workbench Parameter
Treat Measures as Elevation
SEARCH_ENVELOPE
Using the minimum and maximum x and y parameters, define a bounding box that will be used to filter the input features. Only features that interact with the bounding box are returned.
If all four coordinates of the search envelope are specified as 0, the search envelope will be disabled.
Mapping File Syntax
<ReaderKeyword>_SEARCH_ENVELOPE <minX> <minY> <maxX> <maxY>
Note: If all four coordinates of the search envelope are specified as zero, the search envelope will be disabled.
Required/Optional
Optional
Workbench Parameter
Minimum X, Minimum Y, Maximum X, Maximum Y
SEARCH_ENVELOPE_COORDINATE_SYSTEM
This directive specifies the coordinate system of the search envelope if it is different than the coordinate system of the data.
The COORDINATE_SYSTEM
directive, which specifies the coordinate system associated with the data to be read, must always be set if the SEARCH_ENVELOPE_COORDINATE_SYSTEM
directive is set.
If this directive is set, the minimum and maximum points of the search envelope are reprojected from the SEARCH_ENVELOPE_COORDINATE_SYSTEM
to the reader COORDINATE_SYSTEM
prior to applying the envelope.
Required/Optional
Optional
Mapping File Syntax
<ReaderKeyword>_SEARCH_ENVELOPE_COORDINATE_SYSTEM <coordinate system>
Workbench Parameter
Search Envelope Coordinate System
CLIP_TO_ENVELOPE
This directive specifies whether or not FME should clip features to the envelope specified in the SEARCH_ENVELOPE
directive.
Values
YES | NO (default)
Mapping File Syntax
<ReaderKeyword>_CLIP_TO_ENVELOPE [yes | no]
Workbench Parameter
Clip To Envelope
EXPOSED_ATTRS
This directive allows the selection of format attributes to be explicitly added to the reader feature type.
This is similar to exposing format attributes on a reader feature type once it has been generated; however, it is even more powerful because it enables schema-driven applications other than Workbench to access and leverage these attributes as if they were explicitly on the schema as user attributes.
The result of picking a list of attributes is a comma-separated list of attribute names and types that will be added to the schema features. Currently all reader feature types will receive the same set of additional schema attributes for a given instance of the reader.
Required/Optional
Optional
Mapping File Syntax
Not applicable.
While it is possible for FME Objects applications to invoke this directive, the required format is not documented.
This directive is intended for use in our GUI applications (for example, Workbench) only.
Workbench Parameter
Additional Attributes to Expose
DISSOLVE HOLES
This specification controls whether the SHAPE reader dissolves adjacent holes in polygons read from shapefiles. If the value is set to yes, then the SHAPE reader will dissolve adjacent holes.
Workbench Parameter: Dissolve Adjacent Holes
REPORT BAD GEOMETRY
This optional specification controls whether the SHAPE reader reports geometric anomalies in input shapefiles.
By default, the SHAPE reader will perform the following operations to ensure the validity of input features: close unclosed polygons, remove duplicate points, remove empty elements, dissolve holes (if DISSOLVE_HOLES is set to YES).
If REPORT_BAD_GEOMETRY is set to YES, then the shape_geometry_error{} list attribute will be set on input features, and will contain error messages as geometric anomalies are detected and/or fixed. The error messages are of the following format:
Closed Polygon at (x,y)
Duplicated Point at (x,y)
Removed Empty Element #n near (x,y)
Removed Duplicate Point at (x,y)
Invalid Polygon/Donut Orientation near (x,y)
Dissolved Holes
Workbench Parameter: Report Geometry Anomalies
ENCODING
This specification controls which character encoding is used to interpret text attributes from the Shapefile. If the value is not set, then the character encoding will be automatically detected from the source Shapefile. If the value is set, it will take precedence over the automatically detected character encoding.
This directive is useful when the character encoding information stored in the Shapefile is missing or incorrect.
Workbench Parameter
Character Encoding
Example:
<ReaderKeyword>_ENCODING <character encoding>
Parameter |
Description |
<character encoding> |
The character encoding to use when interpreting text attributes. Must be set to any of the following values: ANSI - this means use the “current OS language” BIG5 EUC HKBIG5 ISO OEM SJIS UTF-8 CP437 CP708 CP720 CP737 CP775 CP850 CP852 CP855 CP857 CP860 CP861 CP862 CP863 CP864 CP865 CP866 CP869 CP874 CP932 CP936 CP950 CP1250 CP1251 CP1252 CP1253 CP1254 CP1255 CP1256 CP1257 CP1258 ISO8859-1 ISO8859-2 ISO8859-3 ISO8859-4 ISO8859-5 ISO8859-6 ISO8859-7 ISO8859-8 ISO8859-9 ISO8859-11 ISO8859-13 ISO8859-15 WINDOWS-874 |
UPPER_CASE_ATTR_NAMES
This option specifies whether the reader should change attribute names to uppercase text. If set to NO, it will allow mixed case, otherwise attribute names will be made uppercase. The default value is NO; however, for backwards compatibility, when this directive is not present, a value of YES will be used.
Note: This directive is used when generating workspaces and mapping files. As a result, it is not editable within Workbench after the workspace has been generated.
Workbench Parameter: Not applicable.
TRIM_PRECEDING_SPACES
This option specifies whether the reader should trim preceding spaces of attribute values. If the option is set to YES, then preceding spaces in attribute values will be discarded. If the option is set to NO, then preceding spaces will be left intact. The default value is YES.
Workbench Parameter: Trim Preceding Spaces