There is occasionally some confusion around the nature of the Short/Long/Float/Double types in attributes on a Shapefile. The underlying storage for Shapefile stores the values as a fixed-length text field, not a binary representation. This can occasionally cause confusion since other ArcGIS formats do allow binary storage of numeric attributes. This can cause some variations on writing, depending on the source schema.
Shapefile Precision and Scale vs. FME Width and Decimals
In ArcGIS, the precision of a Shapefile's number field refers to the number of total characters that can be stored in that field. This includes the decimal and negative signs, if present, as well as the numbers 0 through 9. In FME, this is referred to as the Width of the field. Scale and Decimals both represent the number of digits that come after the decimal. ArcGIS does have some quirks about displaying these, however:
- A Float with Precision and Scale of 13, 11 will display in ArcGIS as Float(0,0), but FME reports an fme_decimal(13,11).
- Doubles with Precision and Scale of 19, 11 will display in ArcGIS as Double(0,0), but FME reports an fme_decimal(19,11).
- Since ArcGIS 10.3.1, an integer field of width 5 is shown as Long Integer, but the default width of a Short Integer is 5. A newly created attribute with the Short Integer type and unspecified width will, when the properties window is reopened, immediately be displayed as a Long Integer with a width of 5.
The Float(0,0) and Double(0,0) is a result of ArcGIS supporting a number of other formats – any fields with 0, 0 as their precision and scale will be stored in binary only if the format supports it – Shapefiles are not one of these formats. In a Shapefile, these will be the same as a Float(13,11) and Double(19,11) respectively. If Numeric Attribute Type Handling is set to Preserve Fixed-Width Numeric Field Size, FME will always report the actual width and decimals of the field.
Widths of Numeric Attributes are Inflated on Write
When FME writes to Shapefile, it has to convert any numeric attributes from binary to text, and in order to do so, selects a field width that can represent the full range of values of that binary representation. This can mean that a 16-bit integer that was originally stored as 3 characters in a Shapefile will be written out as a 6-character field. Since the range of values of a 16-bit integer is -32,768 to 32,767, in order to represent the negative end of that range as text, 6 characters are required: -32768, since without the negative sign the number will be read back as positive.
If you are finding that FME is inflating the field width of your numeric attributes, you can select the reader's parameters in the Workbench Navigator, and change the Numeric Attribute Type Handling option to Explicit Width and Precision. This will cause FME to keep the attributes as fixed-width numeric fields rather than converting to binary representation and making the writer guess the field widths.
Numbers are Being Stored as Text
When reading from a Shapefile and converting to another format, it is possible that FME will choose a text or string type to store that attribute. For example, if converting to a database format, a Shapefile number(5,0) may be converted to a char(5) instead of a short int.
To make FME convert number fields to their binary representation, change the reader's Numeric Attribute Type Handling option to Standard Types, and the smallest integer type that can represent all values of that fixed-width number will be used instead.