Vector Layer
The VectorLayer module provides functionality for working with vector data layers.
- class VectorLayer(api, uuid, layer_type, data={})[source]
A class representing a vector layer in Geobox.
This class provides functionality to create, manage, and manipulate vector layers. It supports various operations including CRUD operations on layers, features, and fields, as well as advanced operations like importing/exporting features and calculating field values.
- Parameters:
api (GeoboxClient)
uuid (str)
layer_type (LayerType)
data (Dict | None)
- __init__(api, uuid, layer_type, data={})[source]
Initialize a VectorLayer instance.
- Parameters:
api (GeoboxClient) – The GeoboxClient instance for making requests.
uuid (str) – The unique identifier for the layer.
layer_type (LayerType) – The type of geometry stored in the layer.
data (Dict, optional) – Additional layer metadata and configuration.
- __repr__()[source]
Return a string representation of the VectorLayer object.
- Returns:
A string representation of the VectorLayer object.
- Return type:
str
- classmethod get_vectors(api, **kwargs)[source]
Get a list of vector layers with optional filtering and pagination.
- Parameters:
api (GeoboxClient) – The GeoboxClient instance for making requests.
- Keyword Arguments:
include_settings (bool) – Whether to include layer settings. Default is False.
temporary (bool) – Whether to return temporary layers, default is False
q (str) – Query filter based on OGC CQL standard. e.g. “field1 LIKE ‘%GIS%’ AND created_at > ‘2021-01-01’”
search (str) – Search term for keyword-based searching among search_fields or all textual fields if search_fields does not have value. NOTE: if q param is defined this param will be ignored.
search_fields (str) – Comma separated list of fields for searching
order_by (str) – comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: “A” denotes ascending order and “D” denotes descending order.
return_count (bool) – Whether to return total count. default is False.
skip (int) – Number of layers to skip. default is 0.
limit (int) – Maximum number of layers to return. default is 10.
user_id (int) – Specific user. privileges required.
shared (bool) – Whether to return shared layers. default is False.
- Returns:
A list of VectorLayer instances or the layers count if return_count is True.
- Return type:
List[VectorLayer] | int
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layers = VectorLayer.get_vectors(api=client, ... include_settings=True, ... skip=0, ... limit=100, ... return_count=False, ... search="my_layer", ... search_fields="name, description", ... order_by="name", ... shared=True) or >>> layers = client.get_vectors(include_settings=True, ... skip=0, ... limit=100, ... return_count=False, ... search="my_layer", ... search_fields="name, description", ... order_by="name", ... shared=True)
- classmethod get_vector(api, uuid, user_id=None)[source]
Get a specific vector layer by its UUID.
- Parameters:
api (GeoboxClient) – The GeoboxClient instance for making requests.
uuid (str) – The UUID of the layer to retrieve.
user_id (int, optional) – Specific user. privileges required.
- Returns:
The requested layer instance.
- Return type:
- Raises:
NotFoundError – If the layer with the specified UUID is not found.
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = VectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678") or >>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
- classmethod get_vector_by_name(api, name, user_id=None)[source]
Get a vector layer by name
- Parameters:
api (GeoboxClient) – The GeoboxClient instance for making requests.
name (str) – the name of the vector to get
user_id (int, optional) – specific user. privileges required.
- Returns:
returns the vector if a vector matches the given name, else None
- Return type:
VectorLayer | None
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = VectorLayer.get_vector_by_name(client, name='test') or >>> layer = client.get_vector_by_name(name='test')
- classmethod get_vectors_by_ids(api, ids, user_id=None, include_settings=False)[source]
Get vector layers by their IDs.
- Parameters:
api (GeoboxClient) – The GeoboxClient instance for making requests.
ids (List[int]) – The IDs of the layers to retrieve.
user_id (int, optional) – Specific user. privileges required.
include_settings (bool, optional) – Whether to include the layer settings. default is False.
- Returns:
The list of VectorLayer instances.
- Return type:
List[VectorLayer]
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layers = VectorLayer.get_vectors_by_ids(api=client, ids=[1, 2, 3]) or >>> layers = client.get_vectors_by_ids(ids=[1, 2, 3])
- classmethod create_vector(api, name, layer_type, display_name=None, description=None, has_z=False, temporary=False, fields=None)[source]
Create a new vector layer.
- Parameters:
api (GeoboxClient) – The GeoboxClient instance for making requests.
name (str) – The name of the layer.
layer_type (LayerType) – The type of geometry to store.
display_name (str, optional) – A human-readable name for the layer. default is None.
description (str, optional) – A description of the layer. default is None.
has_z (bool, optional) – Whether the layer includes Z coordinates. default is False.
temporary (bool, optional) – Whether to create a temporary layer. temporary layers will be deleted after 24 hours. default is False.
fields (List, optional) – List of field definitions for the layer. default is None.
- Returns:
The newly created layer instance.
- Return type:
- Raises:
ValidationError – If the layer data is invalid.
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = VectorLayer.create_vector(api=client, ... name="my_layer", ... layer_type=LayerType.Point, ... display_name="My Layer", ... description="This is a description of my layer", ... has_z=False, ... temporary=True, ... fields=[{"name": "my_field", "datatype": "FieldTypeString"}]) or >>> layer = client.create_vector(name="my_layer", ... layer_type=LayerType.Point, ... display_name="My Layer", ... description="This is a description of my layer", ... has_z=False, ... temporary=True, ... fields=[{"name": "my_field", "datatype": "FieldTypeString"}])
- update(**kwargs)[source]
Update the layer’s properties.
- Keyword Arguments:
name (str) – The new name for the layer.
display_name (str) – The new display name for the layer.
description (str) – The new description for the layer.
- Returns:
The updated layer data.
- Return type:
Dict
- Raises:
ValidationError – If the update data is invalid.
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = VectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> layer.update(name="new_name") >>> layer.update(display_name="new_display_name") >>> layer.update(description="new_description")
- delete()[source]
Delete the layer.
- Returns:
None
- Return type:
None
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = VectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> layer.delete()
- make_permanent()[source]
Make the layer permanent.
- Returns:
None
- Return type:
None
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = VectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> layer.make_permanent()
- make_temporary()[source]
Make the layer permanent.
- Returns:
None
- Return type:
None
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = VectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> layer.make_temporary()
Shares the layer with specified users.
- Parameters:
users (List[User]) – The list of user objects to share the layer with.
- Returns:
None
- Return type:
None
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = VectorLayer.get_vector(client, uuid="12345678-1234-5678-1234-567812345678") >>> users = client.search_users(search="John") >>> layer.share(users=users)
Unshares the layer with specified users.
- Parameters:
users (List[User]) – The list of user objectss to unshare the layer with.
- Returns:
None
- Return type:
None
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = VectorLayer.get_vector(client, uuid="12345678-1234-5678-1234-567812345678") >>> users = client.search_users(search="John") >>> layer.unshare(users=users)
Retrieves the list of users the layer is shared with.
- Parameters:
search (str, optional) – The search query.
skip (int, optional) – The number of users to skip.
limit (int, optional) – The maximum number of users to retrieve.
- Returns:
The list of shared users.
- Return type:
List[User]
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = VectorLayer.get_vector(client, uuid="12345678-1234-5678-1234-567812345678") >>> layer.get_shared_users(search='John', skip=0, limit=10)
- create_version(name, display_name=None, description=None)[source]
Create a version from the layer
- Parameters:
name (str) – the name of the version.
display_name (str, optional) – the display name of the version.
description (str, optional) – the description of the version.
- Returns:
the object of the version.
- Return type:
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectoLayer >>> client = GeoboxClient() >>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678") >>> version = layer.create_version(name="my_version")
- get_versions(**kwargs)[source]
Get list of versions of the current vector layer object with optional filtering and pagination.
- Keyword Arguments:
q (str) – query filter based on OGC CQL standard. e.g. “field1 LIKE ‘%GIS%’ AND created_at > ‘2021-01-01’”
search (str) – search term for keyword-based searching among search_fields or all textual fields if search_fields does not have value. NOTE: if q param is defined this param will be ignored.
search_fields (str) – comma separated list of fields for searching.
order_by (str) – comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: “A” denotes ascending order and “D” denotes descending order.
return_count (bool) – Whether to return total count. default is False.
skip (int) – Number of items to skip. default is 0.
limit (int) – Number of items to return. default is 10.
user_id (int) – Specific user. privileges required.
shared (bool) – Whether to return shared versions. default is False.
- Returns:
A list of vector layer version instances or the total number of versions.
- Return type:
List[VectorLayerVersion] | int
Example
>>> from geobox import GeoboxClient >>> from geobox.version import VectorLayerVersion >>> client = GeoboxClient() >>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678") >>> versions = layer.get_versions() or >>> versions = layer.get_versions()
- property wfs: str
Get the WFS endpoint for the layer.
- Returns:
The WFS endpoint for the layer.
- Return type:
str
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = VectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> layer.wfs
- get_fields()[source]
Get all fields in the layer.
- Returns:
A list of Field instances representing the layer’s fields.
- Return type:
List[Field]
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = VectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> fields = layer.get_fields()
- get_field(field_id)[source]
Get a specific field by its ID.
- Parameters:
field_id (int, optional) – The ID of the field to retrieve.
- Returns:
The requested field instance.
- Return type:
- Raises:
NotFoundError – If the field with the specified ID is not found.
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = VectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> field = layer.get_field(field_id=1)
- get_field_by_name(name)[source]
Get a specific field by its name.
- Parameters:
name (str) – The name of the field to retrieve.
- Returns:
The requested field instance.
- Return type:
- Raises:
NotFoundError – If the field with the specified name is not found.
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = VectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> field = layer.get_field_by_name(name='test')
- add_field(name, data_type, data={})[source]
Add a new field to the layer.
- Parameters:
name (str) – The name of the new field.
data_type (FieldType) – The data type of the new field.
data (Dict) – Additional field properties (display_name, description, etc.).
- Returns:
The newly created field instance.
- Return type:
- Raises:
ValidationError – If the field data is invalid.
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = VectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> field = layer.add_field(name="new_field", data_type=FieldType.String)
- calculate_field(target_field, expression, q=None, bbox=None, bbox_srid=None, feature_ids=None, run_async=True, user_id=None)[source]
Calculate values for a field based on an expression.
- Parameters:
target_field (str) – The field to calculate values for.
expression (str) – The expression to use for calculation.
q (str, optional) – Query to filter features. default is None.
bbox (List, optional) – Bounding box to filter features. default is None.
bbox_srid (int, optional) – Spatial reference ID for the bounding box. default is None.
feature_ids (List, optional) – List of specific feature IDs to include. default is None
run_async (bool, optional) – Whether to run the calculation asynchronously. default is True.
user_id (int, optional) – Specific user. privileges required.
- Returns:
The task instance of the calculation operation or the api response if the run_async=False.
- Return type:
Task | Dict
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = VectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> task = layer.calculate_field(target_field="target_field", ... expression="expression", ... q="name like 'my_layer'", ... bbox=[10, 20, 30, 40], ... bbox_srid=3857, ... feature_ids=[1, 2, 3], ... run_async=True)
- get_features(geojson=False, **kwargs)[source]
Get features from the layer with optional filtering and pagination.
- Parameters:
geojson (bool, optional) – If True, returns the raw API response (GeoJSON dict). If False, returns a list of Feature objects. default: False.
- Keyword Arguments:
relationship_uuid (str) – The uuid of relationship
related_record_id (int) – This is the id of the feature or row that these features are related to. This id blongs to the related layer or table not this layer
quant_factor (int) – Quantization factor. This parameter is only used by topojson encoder and is ignored for other formats. Higher quantizaion value means higher geometry precision. default is 1000000.
skip (int) – Number of features to skip. default is 0.
limit (int) – Maximum number of features to return. default is 100.
user_id (int) – Specific user. privileges required.
search (str) – search term for keyword-based searching among search_fields or all textual fields if search_fields does not have value. NOTE: if q param is defined this param will be ignored.
search_fields (str) – comma separated list of fields for searching.
skip_geometry (bool) – Whether to exclude geometry data. default is False.
return_count (bool) – Whether to return total count. default is False.
feature_ids (list) – Comma separated list of feature ids which should be filtered.
select_fields (str) – comma separated field names which should be included to the result. default is “[ALL]”.
skip_fields (str) – comma separated field names which should be excluded from the result.
out_srid (int) – srid (epsg code) of result features. e.g. 4326. default is 3857.
order_by (str) – comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, length D. NOTE: “A” denotes ascending order and “D” denotes descending order.
q (str) – query filter based on OGC CQL standard. e.g. Name LIKE ‘%GIS%’ AND INTERSECTS(geometry, ‘SRID=3857;POLYGON((4901948 2885079, 7049893 2885079, 7049893 4833901, 4901948 4833901, 4901948 2885079))’).
bbox (str) – Bounding box to filter features by. e.g. [50.275, 35.1195, 51.4459, 36.0416].
bbox_srid (int) – srid (epsg code) of bbox. e.g. 4326. default is 3857.
- Returns:
A list of Feature instances or the geojson api response if geojson=True or the features count if return_count is True.
- Return type:
List[Feature] | Dict | int
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = VectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> features = layer.get_features(quant_factor=1000000, ... skip=0, ... limit=100, ... skip_geometry=False, ... return_count=False, ... select_fields="fclass, osm_id", ... out_srid=3857, ... bbox_srid=3857)
- get_feature(feature_id, out_srid=3857)[source]
Get a specific feature by its ID.
- Parameters:
feature_id (int) – The ID of the feature to retrieve.
out_srid (int, optional) – Output spatial reference ID. default is 3857.
- Returns:
The requested feature instance.
- Return type:
- Raises:
NotFoundError – If the feature with the specified ID is not found.
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = VectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> feature = layer.get_feature(feature_id=1, out_srid=4326)
- create_feature(geojson, srid=3857)[source]
Create a new feature in the layer.
- Parameters:
geojson (Dict) – The feature data including properties and geometry.
srid (int, optional) – the feature srid. default: 3857
- Returns:
The newly created feature instance.
- Return type:
- Raises:
ValidationError – If the feature data is invalid.
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = VectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> geojson = { ... "type": "Feature", ... "geometry": {"type": "Point", "coordinates": [10, 20]}, ... "properties": {"name": "My Point"} ... } >>> feature = layer.create_feature(geojson=geojson)
- delete_features(q=None, bbox=None, bbox_srid=None, feature_ids=None, run_async=True, user_id=None)[source]
Delete features from the layer based on specified criteria.
- Parameters:
q (str, optional) – Query to filter features to delete.
bbox (str, optional) – Comma seprated bbox.
bbox_srid (int, optional) – Spatial reference ID for the bounding box.
feature_ids (str, optional) – Comma seprated feature ids.
run_async (bool, optional) – Whether to run the deletion asynchronously. default is True.
user_id (int, optional) – Specific user. privileges required.
- Returns:
The task instance of the deletion operation or the api response if run_async=False.
- Return type:
Task | Dict
- Raises:
ValidationError – If the deletion parameters are invalid.
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = VectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> layer.delete_features(q="name like 'my_layer'", ... bbox='10, 20, 30, 40', ... bbox_srid=3857, ... feature_ids='1, 2, 3', ... run_async=True)
- import_features(file, input_geom_type=None, input_layer_name=None, input_dataset=None, user_id=None, input_srid=None, file_encoding='utf-8', replace_domain_codes_by_values=False, report_errors=True)[source]
Import features from a file into the layer.
- Parameters:
file (File) – file object to import.
input_geom_type (InputGeomType, optional) – Type of geometry in the input file.
input_layer_name (str, optional) – Name of the layer in the input file.
input_dataset (str, optional) – Name of the dataset in the input file.
user_id (int, optional) – Specific user. privileges required.
input_srid (int, optional) – Spatial reference ID of the input data.
file_encoding (str, optional) – Character encoding of the input file.
replace_domain_codes_by_values (bool, optional) – Whether to replace domain codes with values.
report_errors (bool, optional) – Whether to report import errors.
- Returns:
The task instance of the import operation.
- Return type:
- Raises:
ValidationError – If the import parameters are invalid.
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = VectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> file = client.get_file(uuid="12345678-1234-5678-1234-567812345678") >>> task = layer.import_features(file=file, ... input_geom_type=InputGeomType.POINT, ... input_layer_name="my_layer", ... input_dataset="my_dataset", ... input_srid=3857, ... file_encoding="utf-8", ... replace_domain_codes_by_values=False, ... report_errors=True)
- export_features(out_filename, out_format, replace_domain_codes_by_values=False, run_async=True, bbox=None, out_srid=None, zipped=True, feature_ids=None, bbox_srid=None, q=None, fields=None)[source]
Export features from the layer to a file.
- Parameters:
out_filename (str) – Name of the output file.
out_format (FileOutputFormat) – Format of the output file (e.g., ‘Shapefile’, ‘GPKG’, ‘GeoJSON’, ‘CSV’, ‘KML’, ‘DXF’).
replace_domain_codes_by_values (bool, optional) – Whether to replace domain codes with values.
run_async (bool, optional) – Whether to run the export asynchronously.
bbox (List, optional) – Bounding box to filter features.
out_srid (int) – Spatial reference ID for the output.
zipped (bool, optional) – Whether to compress the output file.
feature_ids (List[int], optional) – List of specific feature IDs to export.
bbox_srid (int, optional) – Spatial reference ID for the bounding box.
q (str, optional) – Query to filter features.
fields (List[str], optional) – List of fields to include in the export.
- Returns:
The task instance of the export operation or the api response if run_async=False.
- Return type:
Task | Dict
- Raises:
ValidationError – If the export parameters are invalid.
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = VectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> task = layer.export_features(out_filename="output.shp", ... out_format="shp", ... replace_domain_codes_by_values=False, ... run_async=True, ... bbox=[10, 20, 30, 40], ... out_srid=3857, ... zipped=True, ... feature_ids=[1, 2, 3])
- create_view(name, display_name=None, description=None, view_filter=None, view_extent=None, view_cols=None)[source]
Create a view of the vector layer.
- Parameters:
name (str) – The name of the view.
display_name (str, optional) – The display name of the view.
description (str, optional) – The description of the view.
view_filter (str, optional) – The filter for the view.
view_extent (List[float], optional) – The extent of the view.
view_cols (str, optional) – The columns to include in the view.
- Returns:
The created view instance.
- Return type:
- Raises:
ValidationError – If the view parameters are invalid.
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = VectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> view = layer.create_view(name="my_view", ... display_name="My View", ... description="This is a view of my layer", ... view_filter="province_name = 'Tehran'", ... view_extent=[10, 20, 30, 40], ... view_cols="[ALL]")
- property tile_pbf_url: str
Get a vector tile pbf url for the layer.
- Returns:
The vector tile url.
- Return type:
str
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = VectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> url = layer.tile_pbf_url
- get_tile_json()[source]
Get the vector tile JSON configuration for the layer.
- Returns:
The vector tile JSON configuration.
- Return type:
Dict
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = VectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> tile_json = layer.get_tile_json()
- property settings: Dict
Get the layer’s settings.
- Returns:
The layer settings.
- Return type:
Dict
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = VectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> setting = layer.setting
- update_settings(settings)[source]
Update the settings
settings (Dict): settings dictionary
- Returns:
updated settings
- Return type:
Dict
- Parameters:
settings (Dict)
Example
>>> from geobox import GeoboxClient >>> client = GeoboxClient() >>> layer1 = client.get_vector(uuid="12345678-1234-5678-1234-567812345678") >>> layer2 = client.get_vector(uuid="12345678-1234-5678-1234-567812345678") >>> layer1.update_settings(layer2.settings)
- set_settings(**kwargs)[source]
Set the settings of the Vector Layer.
- Keyword Arguments:
title_field (str) – The field to use as the title.
domain_display_type (str) – The type of domain display.
allow_export (bool) – Whether to allow export.
editable (bool) – Whether to allow editing.
edit_geometry (bool) – Whether to allow editing the geometry.
editable_attributes (str) – The attributes to allow editing.
allow_insert (bool) – Whether to allow inserting.
allow_delete (bool) – Whether to allow deleting.
min_zoom (int) – The minimum zoom level.
max_zoom (int) – The maximum zoom level.
max_features (int) – The maximum number of features.
filter_features (bool) – Whether to filter features.
fields (List[str]) – The fields to include in the layer.
use_cache (bool) – Whether to use caching.
cache_until_zoom (int) – The zoom level to cache until.
- Returns:
The updated settings.
- Return type:
Dict
- Raises:
ValidationError – If the settings data is invalid.
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = VectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> layer.set_settings(title_field="name", ... domain_display_type="Value", ... allow_export=True, ... editable=True, ... edit_geometry=True, ... editable_attributes="[ALL]", ... allow_insert=True, ... allow_delete=True, ... min_zoom=0, ... max_zoom=24, ... max_features=65536, ... filter_features=True, ... fields=["id"], ... use_cache=True, ... cache_until_zoom=17)
- seed_cache(from_zoom=None, to_zoom=None, ignore_cache=False, workers=1, user_id=None)[source]
Seed the cache for the layer.
- Parameters:
from_zoom (int, optional) – The zoom level to start caching from.
to_zoom (int, optional) – The zoom level to stop caching at.
ignore_cache (bool, optional) – Whether to ignore the cache. default is False.
workers (int, optional) – The number of workers to use. default is 1.
user_id (int, optional) – Specific user. privileges required.
- Returns:
The task instance of the cache seeding operation.
- Return type:
List[Task]
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = VectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> task = layer.seed_cache(from_zoom=0, to_zoom=10, ignore_cache=False, workers=1)
- clear_cache()[source]
Clear the layer’s cache.
- Returns:
None
- Return type:
None
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = VectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> layer.clear_cache()
- property cache_size: int
Get the size of the layer’s cache.
- Returns:
The size of the layer’s cache.
- Return type:
int
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = VectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> layer.cache_size
- update_stats()[source]
Update the layer’s statistics.
- Returns:
None
- Return type:
None
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = VectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> layer.update_stats()
- prune_edited_areas()[source]
Prune edited areas. This method eliminates edited areas when there are too many of them. Cache builder uses this edited areas for partial cache generating.
- Returns:
None
- Return type:
None
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = VectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> layer.prune_edited_areas()
- get_attachments(**kwargs)[source]
Get the resouces attachments
- Keyword Arguments:
element_id (str) – the id of the element with attachment.
search (str) – search term for keyword-based searching among all textual fields.
order_by (str) – comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: “A” denotes ascending order and “D” denotes descending order.
skip (int) – Number of items to skip. default is 0.
limit (int) – Number of items to return. default is 10.
return_count (bool) – Whether to return total count. default is False.
- Returns:
A list of attachments instances or the total number of attachments.
- Return type:
List[Attachment] | int
- Raises:
TypeError – if the resource type is not supported
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = VectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> layer.get_attachments()
- create_attachment(name, loc_x, loc_y, file, feature=None, display_name=None, description=None)[source]
Create a new Attachment.
- Parameters:
name (str) – The name of the scene.
loc_x (int) – x parameter of the attachment location.
loc_y (int) – y parameter of the attachment location.
file (File) – the file object.
feature (Feature, optional) – the feature object.
display_name (str, optional) – The display name of the scene.
description (str, optional) – The description of the scene.
- Returns:
The newly created Attachment instance.
- Return type:
- Raises:
ValidationError – If the Attachment data is invalid.
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = VectorLayer.get_vector(api=client, uuid="12345678-1234-5678-1234-567812345678") >>> file = client.get_file(uuid="12345678-1234-5678-1234-567812345678") >>> layer.create_attachment(name='test', loc_x=10, loc_y=10, file=file)
- get_relations()[source]
Get the relationships that include this layer
- Returns:
list of the relationships
- Return type:
List[Relationship]
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678") or >>> layer = VectorLayer.get_vector(client, uuid="12345678-1234-5678-1234-567812345678") >>> relationships = layer.get_relations()
- generate_thumbnail()[source]
Generate thumbnail for the layer
- Returns:
the api response
- Return type:
Dict
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678") or >>> layer = VectorLayer.get_vector(client, uuid="12345678-1234-5678-1234-567812345678") >>> layer.generate_thumbnail()
- save_as_vector_layer(out_layer_name, q=None, bbox=None, bbox_srid=None, fields=None, schema_only=False, run_async=True)[source]
Copy filtered/selected features of a vector layer into a new vector layer.
- Parameters:
out_layer_name (str) – the output vector layer name
q (str, optional) – Query filter based on OGC CQL standard. e.g. “field1 LIKE ‘%GIS%’ AND created_at > ‘2021-01-01’”
bbox (str, optional) – Bounding box to filter features
bbox_srid (int, optional) – Spatial reference ID for the bounding box
fields (str, optional) – Comma separated list of fields
feature_ids (str, optional) – Comma seprated feature ids
schema_only (bool, optional) – Whether to save the layer schema only
run_async (bool, optional) – Whether to run the task asynchronously
- Returns:
a task instance if ‘run_async == True’, else the task result dictionary
- Return type:
Task | Dict
Example
>>> from geobox import GeoboxClient >>> from geobox.vectorlayer import VectorLayer >>> client = GeoboxClient() >>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678") or >>> layer = VectorLayer.get_vector(client, uuid="12345678-1234-5678-1234-567812345678") >>> layer.save_as_vector_layer(out_layer_name='test')