Python client to interact with a running k.LAB Engine.
Project description
k.LAB CLient Python
A Python client library to interact with a running (local or remote) k.LAB Engine.
Usage example: observe elevation on a given region
Note that asyncio is used to handle async elaborations.
- add necessary imports and create a new client instance
from klab.klab import Klab
from klab.geometry import GeometryBuilder
from klab.observable import Observable
from klab.observation import Observation
from klab.utils import Export, ExportFormat
import asyncio
klab = Klab.create()
- define a geometry to use as context through its WKT definition
ruaha = "EPSG:4326 POLYGON((33.796 -7.086, 35.946 -7.086, 35.946 -9.41, 33.796 -9.41, 33.796 -7.086))"
- create a semantic type and a geometry
obs = Observable.create("earth:Region")
grid = GeometryBuilder().grid(urn= ruaha, resolution= "1 km").years(2010).build()
- submit them to the engine and obtain the context
ticketHandler = self.klab.submit(obs, grid)
context = await ticketHandler.get()
- create the elevation observable and submit it to the context
obsElev = Observable.create("geography:Elevation")
ticketHandler = context.submit(obsElev)
elevation = await ticketHandler.get()
- export the observation to a geotiff
path = "your path here"
elevation.exportToFile(Export.DATA, ExportFormat.GEOTIFF_RASTER, path)
For more examples have a look at the testcases in the repository.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file klab-client-py-0.1.0.tar.gz.
File metadata
- Download URL: klab-client-py-0.1.0.tar.gz
- Upload date:
- Size: 40.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c54ae3c971698b632272cad538dc90af01efd2dabe6e5b389a7fe027408ea2ed
|
|
| MD5 |
ed583d3340c3323c4fac85f671fe509b
|
|
| BLAKE2b-256 |
8d0baa68c852cb206813750906ce3c708c67f98894fdc0e631854e47c56487a8
|
File details
Details for the file klab_client_py-0.1.0-py3-none-any.whl.
File metadata
- Download URL: klab_client_py-0.1.0-py3-none-any.whl
- Upload date:
- Size: 40.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
374c293aeb088d24b3e72d582fb8c9271b99c10cc3a182fd55b30afbb3939db1
|
|
| MD5 |
56539f6fc9cb0b775bd1904b43c95cc0
|
|
| BLAKE2b-256 |
9a3f1c27f478c94658edfe42ce9f37a42051a59e31b66f1c28c3dbd3d9090a66
|