Wrap an OGR Field. Needs to be instantiated from a Feature object.
Attributes
| Attribute | Type | Description |
|---|
| ptr | pointer | Internal pointer to the OGR Field definition used for interacting with the underlying GDAL C API. |
| is_set | boolean | Return True if the value of this field isn't null, False otherwise. |
| name | string | Return the name of this Field. |
| precision | integer | Return the precision of this Field. |
| type | integer | Return the OGR type of this Field. |
| type_name | string | Return the OGR field type name for this Field. |
| value | any | Return the value of this Field. |
| width | integer | Return the width of this Field. |
Constructor
Signature
def Field(
feat: [Feature](../feature/feature.md?sid=django_contrib_gis_gdal_feature_feature),
index: int
)
Parameters
| Name | Type | Description |
|---|
| feat | [Feature](../feature/feature.md?sid=django_contrib_gis_gdal_feature_feature) | The feature object containing the field. |
| index | int | The integer index of the field within the feature. |
Signature
def Field(
feat: [Feature](../feature/feature.md?sid=django_contrib_gis_gdal_feature_feature),
index: int
)
Parameters
| Name | Type | Description |
|---|
| feat | [Feature](../feature/feature.md?sid=django_contrib_gis_gdal_feature_feature) | The OGR Feature object that contains this field |
| index | int | The zero-based integer index of the field within the feature's definition |
Methods
as_double()
@classmethod
def as_double() - > float
Retrieve the Field's value as a double (float).
Returns
| Type | Description |
|---|
float | The field value as a float, or None if the field is not set |
as_int()
@classmethod
def as_int(
is_64: bool = False
) - > int
Retrieve the Field's value as an integer.
Parameters
| Name | Type | Description |
|---|
| is_64 | bool = False | Determines whether to retrieve the value as a 64-bit integer |
Returns
| Type | Description |
|---|
int | The field value as an integer, or None if the field is not set |
as_string()
@classmethod
def as_string() - > str
Retrieve the Field's value as a string.
Returns
| Type | Description |
|---|
str | The field value converted to a string using the feature's encoding, or None if not set |
as_datetime()
@classmethod
def as_datetime() - > tuple
Retrieve the Field's value as a tuple of date & time components.
Returns
| Type | Description |
|---|
tuple | A tuple containing (year, month, day, hour, minute, second, timezone) |
is_set()
@classmethod
def is_set() - > bool
Return True if the value of this field isn't null, False otherwise.
Returns
| Type | Description |
|---|
bool | Boolean indicating if the field contains a non-null value |
name()
@classmethod
def name() - > str
Return the name of this Field.
Returns
| Type | Description |
|---|
str | The name of the field as defined in the OGR layer |
precision()
@classmethod
def precision() - > int
Return the precision of this Field.
Returns
| Type | Description |
|---|
int | The number of digits after the decimal point for the field |
type()
@classmethod
def type() - > int
Return the OGR type of this Field.
Returns
| Type | Description |
|---|
int | The integer constant representing the OGR Field Type (OFT) |
type_name()
@classmethod
def type_name() - > str
Return the OGR field type name for this Field.
Returns
| Type | Description |
|---|
str | The human-readable string name of the OGR field type |
value()
@classmethod
def value() - > any
Return the value of this Field.
Returns
| Type | Description |
|---|
any | The underlying value of the field, typically returned as a string by default |
width()
@classmethod
def width() - > int
Return the width of this Field.
Returns
| Type | Description |
|---|
int | The maximum width of the field |