Async Field
The async Field module provides functionality for working with fields of a vector layer.
- class AsyncField(layer, data_type, field_id=None, data={})[source]
Bases:
AsyncBase- Parameters:
layer (VectorLayer)
data_type (FieldType)
field_id (int)
data (Dict | None)
- __init__(layer, data_type, field_id=None, data={})[source]
Constructs all the necessary attributes for the Field object.
- Parameters:
layer (VectorLayer) – The vector layer that the field belongs to.
data_type (FieldType) – type of the field
field_id (int) – the id of the field
data (Dict, optional) – The data of the field.
- __repr__()[source]
Return a string representation of the field.
- Returns:
The string representation of the field.
- Return type:
str
- __getattr__(name)[source]
Get an attribute from the resource.
- Parameters:
name (str) – The name of the attribute
- Return type:
Any
- property domain: Dict
Domain property
- Returns:
domain data
- Return type:
Dict
- async classmethod create_field(api, layer, name, data_type, data={})[source]
[async] Create a new field
- Parameters:
api (AsyncGeoboxClient) – The AsyncGeoboxClient instance for making requests.
layer (VectorLayer) – field’s layer
name (str) – name of the field
data_type (FieldType) – type of the field
data (Dict, optional) – the data of the field
- Returns:
the created field object
- Return type:
Example
>>> from geobox.aio import AsyncGeoboxClient >>> from geobox.aio.vectorlayer import VectorLayer >>> from geobox.aio.field import AsyncField >>> async with AsyncGeoboxClient() as client: >>> layer = await client.get_layer(uuid="12345678-1234-5678-1234-567812345678") >>> field = await AsyncField.create_field(client, layer=layer, name='test', data_type=FieldType.Integer)
- async save()[source]
[async] Save the field. Creates a new field if field_id is None, updates existing field otherwise.
- Returns:
None
- Return type:
None
Example
>>> from geobox.aio import AsyncGeoboxClient >>> from geobox.aio.field import AsyncField >>> async with AsyncGeoboxClient() as client: >>> layer = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678") >>> field = AsyncField(layer=layer, data_type=FieldType.String) >>> await field.save()
- async delete()[source]
[async] Delete the field.
- Returns:
None
- Return type:
None
Example
>>> from geobox.aio import AsyncGeoboxClient >>> async with AsyncGeoboxClient() as client: >>> layer = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678") >>> field = await layer.get_field(name='test') >>> await field.delete()
- async update(**kwargs)[source]
[async] Update the field.
- Keyword Arguments:
name (str) – The name of the field.
display_name (str) – The display name of the field.
description (str) – The description of the field.
domain (Dict) – the domain of the field
width (int) – The width of the field.
hyperlink (bool) – the hyperlink field.
- Returns:
The updated data.
- Return type:
Dict
Example
>>> from geobox.aio import AsyncGeoboxClient >>> async with AsyncGeoboxClient() as client: >>> layer = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678") >>> field = await layer.get_field(name='test') >>> field.update(name="my_field", display_name="My Field", description="My Field Description")
- async get_field_unique_values()[source]
[async] Get the unique values of the field.
- Returns:
The response data.
- Return type:
Dict
Example
>>> from geobox.aio import AsyncGeoboxClient >>> async with AsyncGeoboxClient() as client: >>> layer = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678") >>> field = await layer.get_field(name='test') >>> await field.get_field_unique_values()
- async get_field_unique_values_numbers()[source]
[async] Get the count of unique values of the field.
- Returns:
The count of the field unique values.
- Return type:
int
Example
>>> from geobox.aio import AsyncGeoboxClient >>> async with AsyncGeoboxClient() as client: >>> layer = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678") >>> field = await layer.get_field(name='test') >>> await field.get_field_unique_values_numbers()
- async get_field_statistic(func)[source]
[async] Get the statistic of the field.
- Parameters:
func (str) – The function to apply to the field. values are: min, max, avg
- Returns:
The response data.
- Return type:
Dict
Example
>>> from geobox.aio import AsyncGeoboxClient >>> async with AsyncGeoboxClient() as client: >>> layer = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678") >>> field = await layer.get_field(name='test') >>> await field.get_field_statistic(func='avg')
- async update_domain(range_domain=None, list_domain=None)[source]
[async] Update field domian values
- Parameters:
range_domain (Dict) – a dictionary with min and max keys.
list_domain (Dict) – a dictionary containing the domain codes and values.
- Returns:
the updated field domain
- Return type:
Dict
Example
>>> from geobox.aio import AsyncGeoboxClient >>> async with AsyncGeoboxClient() as client: >>> field = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678").get_fields()[0] >>> range_d = {'min': 1, 'max': 10} >>> list_d = {'1': 'value1', '2': 'value2'} >>> await field.update_domain(range_domain = range_d, list_domain=list_d) {'min': 1, 'max': 10, 'items: {'1': 'value1', '2': 'value2'}}
- async add_index()[source]
[async] Add an index to a field for better query performance
- Returns:
updated field data
- Return type:
Dict
Example
>>> from geobox import GeoboxClient >>> client = GeoboxClient() >>> field = client.get_vector(uuid="12345678-1234-5678-1234-567812345678").get_fields()[0] >>> field.add_index()
- async remove_index()[source]
[async] Remove an index from a field
- Returns:
updated field data
- Return type:
Dict
Example
>>> from geobox import GeoboxClient >>> client = GeoboxClient() >>> field = client.get_vector(uuid="12345678-1234-5678-1234-567812345678").get_fields()[0] >>> field.remove_index()