FieldType

Luo_Suppe2026-08-15

gma.gio.FieldType

[class] FieldType(name = None, dtype = "UNKNOWN"):

Create a FieldType object.

Optional:

name = str||None. Default None.

The name of the field. None for dtype name.

dtype = str. Default 'UNKNOWN'.

The data type of the field. See `dtypes.DefinedFieldDataTypes` for valid types.

Example

from gma import gio

ly = gio.open_vector('Australia.shp')
ftype = ly.ftypes[0]        # first field of the real vector data

print(ftype)
"featurecla" - Type:"String", Width:80, Precision:0

Method

set_precision(precision)

Set the formatting precision for this field in characters.

Parameters:

precision: int.

the new precision.

Returns:

Type: None.

Modify the precision in place.

Example:

from gma import gio

src = gio.open_vector('Australia.shp').ftypes[0]
ftype = gio.FieldType(src.name, src.ftype)     # a modifiable copy of a real field

print('Before:', ftype)
ftype.set_precision(10)
print('After :', ftype)
Before: "featurecla" - Type:"String", Width:0, Precision:0
After : "featurecla" - Type:"String", Width:0, Precision:10

set_type(f_dtype)

Set the formatting width for this field in characters.

Parameters:

f_dtype: int||str.

the new field data type

Returns:

Type: None.

Modify the field data type in place.

Example:

from gma import gio

src = gio.open_vector('Australia.shp').ftypes[0]
ftype = gio.FieldType(src.name, src.ftype)     # a modifiable copy of a real field

print('Before:', ftype)
ftype.set_type('Integer')
print('After :', ftype)
Before: "featurecla" - Type:"String", Width:0, Precision:0
After : "featurecla" - Type:"Integer", Width:0, Precision:0

set_width(width)

Set the formatting width for this field in characters.

Parameters:

width: int.

the new width

Returns:

Type: None.

Modify the field width in place.

Example:

from gma import gio

src = gio.open_vector('Australia.shp').ftypes[0]
ftype = gio.FieldType(src.name, src.ftype)     # a modifiable copy of a real field

print('Before:', ftype)
ftype.set_width(40)
print('After :', ftype)
Before: "featurecla" - Type:"String", Width:0, Precision:0
After : "featurecla" - Type:"String", Width:40, Precision:0

Property

default

Field default value. --> str/int/float/...

Example:

from gma import gio

ftype = gio.open_vector('Australia.shp').ftypes[0]

print(ftype.default)
None

ftype

Field data type. --> str

Example:

from gma import gio

ftype = gio.open_vector('Australia.shp').ftypes[0]

print(ftype.ftype)
String

name

Field name. --> str

Example:

from gma import gio

ftype = gio.open_vector('Australia.shp').ftypes[0]

print(ftype.name)
featurecla

precision

Field precision. --> int

Example:

from gma import gio

ftype = gio.open_vector('Australia.shp').ftypes[0]

print(ftype.precision)
0

width

Field width. --> int

Example:

from gma import gio

ftype = gio.open_vector('Australia.shp').ftypes[0]

print(ftype.width)
80
Last Updated 11/21/2026, 2:33:17 AM