First steps¶
Installation¶
Install the latest Alteia Python package release via pip:
pip install alteia
Configuration¶
To use the SDK, you must configure your Alteia credentials.
To do that, just create a config-connection.json
configuration file:
{
"user": "YOUR_EMAIL_ADDRESS",
"password": "YOUR_ALTEIA_PASSWORD"
}
Depending on your operating system, create the following directory and save the config-connection.json
file in:
(Windows)
%USERPROFILE%\Application\Application Data\Alteia\alteia\
(Linux)
~/.local/share/alteia/
(MacOS)
~/Library/Application Support/alteia/
Note
See the chapter on Configuration for more details about the configuration files.
Using the SDK¶
Any usage starts with the creation of a alteia.sdk.SDK
instance:
>>> import alteia
>>> sdk = alteia.SDK()
Note
Alternatively, if you don’t want to use the SDK with the credentials saved in the default configuration file, you can pass your credentials directly, with:
>>> import alteia
>>> sdk = alteia.SDK(url="https://app.alteia.com/",
... user="YOUR_EMAIL_ADDRESS",
... password="YOUR_ALTEIA_PASSWORD")
Get all the projects available¶
>>> projects = sdk.projects.search(limit=100)
See the projects.search()
documentation.
Get the missions of a project¶
>>> my_project = sdk.projects.search(filter={'name': {'$eq': 'My_project'}})[0]
>>> missions = sdk.missions.search(filter={'project': {'$eq': my_project.id}})
See the missions.search()
documentation.
Explore the dataset properties¶
Let’s print some properties of a dataset:
>>> my_dataset = datasets[0]
>>> print("Name: {}".format(my_dataset.name))
>>> print("Type: {}".format(my_dataset.type))
>>> print("Creation date: {}".format(my_dataset.creation_date))
Some dataset properties depend on its type (image
, raster
, mesh
, pcl
, vector
, file
).
You can list all the available properties for a dataset with:
>>> dir(my_dataset)
To look for the files related to a dataset, we can list the dataset components:
>>> print(my_dataset.components)
Download a dataset component¶
To download a dataset component in the current directory:
>>> component = my_dataset.components[0]
>>> sdk.datasets.download_component(dataset=my_dataset.id,
... component=component.get("name"))
See the datasets.download_component()
documentation.
Create a new dataset¶
To create a new file
dataset related to a project:
>>> new_dataset = sdk.datasets.create_file_dataset(name='My file dataset',
... project=my_project.id)
See the datasets.create_file_dataset()
documentation.
And upload a file:
>>> file_to_upload = "/replace/with/a/file_path.ext"
>>> sdk.datasets.upload_file(dataset=new_dataset.id,
... component='file',
... file_path=file_to_upload)
See the datasets.upload_file()
documentation.
Add a tag¶
Let’s add a tag on the dataset created.
>>> my_tag = sdk.tags.create(name='My tag',
... project=my_project.id,
... type='dataset',
... target=new_dataset.id)
See the tags.create()
documentation.
This tag can be deleted with:
>>> sdk.tags.delete(my_tag.id)
See the tags.delete()
documentation.
Add a comment¶
To add a comment on this dataset:
>>> my_comment = sdk.comments.create(text='This is my first dataset',
... project=my_project.id,
... type='dataset',
... target=new_dataset.id)
See the comments.create()
documentation.
We can mark all the comments of this dataset as read with:
>>> sdk.comments.mark_as_read(project=my_project.id,
... type='dataset',
... target=new_dataset.id)
See the comments.mark_as_read()
documentation.
Add an annotation¶
It is also possible to add an annotation to a project. For example, let’s create one whose geometry is the bounding box of the project:
>>> a = sdk.annotations.create(project=my_project.id,
... geometry=my_project.real_bbox,
... name='Project bounding box',
... description='Bounding box around the project')
See the annotations.create()
documentation.
This annotation can be deleted with:
>>> sdk.annotations.delete(a.id)
See the annotations.delete()
documentation.