Python client for Sintetic Project. This library provides a simple interface to interact with the Sintetic API, allowing users to manage and retrieve data related to synthetic datasets. For more information, visit https://sinteticproject.eu/
Project description
Contents of README.md
Sintetic Library
Description
Python client for Sintetic Project. This library provides a simple interface to interact with the Sintetic API, allowing users to manage and retrieve data related to synthetic datasets. For more information, visit https://sinteticproject.eu/
Intallation
To install the library, you can use pip:
pip install sintetic-library
Use case
from sintetic_library import SinteticClient
# Create an instance of SinteticClient using your Sintetic token.
# The token is issued by your administrator with a specific scope.
#
client = SinteticClient(
token="YOUR TOKEN",
base_url="base URL for Sintetic GeoDB API" # If not specified, SinteticClient will use the staging server API instead of the production one
)
#######
# Sample #1
# Implementation sample for tree processor, forest operation and stan4d files
#######
# Call method for retrieving list of tree processors
result = client.get_list_tree_processors ()
# Retrieve list of forest properties
result = client.get_list_forest_properties ()
# Retrieve list of forest properties
result = client.get_list_forest_properties ()
# Create tree processor id for given data
data = { "name" : "Test Tree Processor",
"type" : "harvester"
}
id_tree_processor = client.create_tree_processor(data)
# Create new forest operation from given data
#
data = { "name" : "Test Forest Operation",
"status" : "planned",
"location": {
"type": "Point",
"coordinates": [10.2, 45.2]
},
"start_date" : "2025-06-19",
"end_date" : "2025-06-19",
"area": 100,
"forest_property_id": "XXXXXXXX-YYYY-ZZZZ-XXXX-ZZZZZZZZZZZZ"
}
id_forest_operation = client.create_forest_operation(data)
# Retrieve list of Stan4D files
response = client.get_stan4d_list()
# Save new Stan4D file
with open("./stan4d_file.hpr", "rb") as f:
xml_content = f.read()
response = client.save_stan4d_object(
filename=os.path.basename(f.name),
xml_content=xml_content,
tree_processor_id=id_tree_processor,
forest_operation_id=id_forest_operation
)
# Extract Stan4D file ID
stand4d_id = response.json()["id"]
# Get Stan4D file using the associated ID
response = client.get_stan4d_file(fileid=stand4d_id)
# Delete Stan4D file using the associated ID
response = client.delete_stan4d_file(fileid=stand4d_id)
# Delete Forest Operation using the associated ID
response = client.delete_forest_operation(forest_operation_id=id_forest_operation)
# Delete Tree Processor using the associated ID
response = client.delete_tree_processor(tree_processor_id=id_tree_processor)
##### End of Sample #1
#####
# Sample #2
# Implementation sample for climate data attachment management
#####
#Open CSV file with climate data
with open("testcsv.csv", "rb") as f:
csv_content = f.read()
# Create new climate object
response = client.save_climate_object(
filename="testcsv.csv",
climate_file=csv_content,
anomalistic=True,
forest_operation_id="24a912c4-6a0a-4860-a163-f62e96f43d6b",
temporal_resolution=TemporalResolution.DAILY.value,
coverage_start_year=2025,
coverage_end_year=2025,
description="Test Climate Attachment"
)
climate_object_id = response
print("Climate object saved successfully:", climate_object_id)
# Retrieve Climate Attachment data
print("Retrieved Climate Attachment data:", client.get_climate_data(climate_object_id))
# Retrieve Climate Attachment file
print("Retrieved Climate file contents:", client.get_climate_file(climate_object_id))
# Delete climate file and data
print("Delete climate file:", client.delete_climate_file(climate_object_id))
#### End of Sample #2
####
# Sample #3
# Implementation sample for subcompartments and vegetation file management
####
#create a new forest operation for subcompartment
data = { "name" : "Test Leandro for Subcompartment",
"status" : "planned",
"location": {
"type": "Point",
"coordinates": [10.2, 45.2]
},
"start_date" : "2025-06-19",
"end_date" : "2025-06-19",
"area": 100,
"forest_property_id": "8a0febff-e133-44fd-8e15-bfa11b40f620"
}
forest_id = client.create_forest_operation(data)
print("Risposta creazione forest operation: ", forest_id)
# Create a new subcompartment
response = client.create_subcompartment("Test subcompartment Leandro", SubcompartmentType.FOREST_OPERATION.value,
forest_id, 10.0, 10.0, 20.0, 20.0)
print(f"Subcompartment created successfully with UUID: {response}")
subcomp_id = response
# Retrieve the list of subcompartments
response = client.get_subcompartments_list()
print(f"List of subcompartments: {response}")
# Retrieve the subcompartment by UUID
response = client.get_subcompartment(subcomp_id)
print(f"Retrieved subcompartment info: {response}")
# Create new vegetation object
# open ndvi file in binary mode
with open("ndvi_july.csv", "rb") as f:
csv_content = f.read()
response = client.save_vegetation_object(
filename="ndvi_july.csv",
vegetation_file=csv_content,
subcompartment_id=subcomp_id,
)
print(f"Vegetation object saved successfully with ID: {response}")
# Retrieve the vegetation data
response = client.get_vegetation_data(subcomp_id)
print(f"Retrieved vegetation file contents: {response}")
# Retrieve vegetation attachments list
response = client.get_vegetation_list()
print(f"Retrieved vegetation attachments list: {response}")
# Retrieve the vegetation object
response = client.get_vegetation_file(subcomp_id)
print(f"Retrieved vegetation file contents: {response}")
#Append new vegetation file
#open ndvi file in binary mode
with open("ndvi_august.csv", "rb") as f:
csv_content = f.read()
response = client.save_vegetation_object(
filename="ndvi_august.csv",
vegetation_file=csv_content,
subcompartment_id=subcomp_id,
)
print(f"Vegetation object saved successfully with ID: {response}")
# Retrieve the updated vegetation object
response = client.get_vegetation_file(subcomp_id)
print(f"Retrieved updated file contents: {response}")
# Delete vegetation file
response = client.delete_vegetation_file(subcomp_id)
print(f"Vegetation file deleted successfully: {response}")
# Delete subcompartment
response = client.delete_subcompartment(subcomp_id)
print(f"Subcompartment deleted successfully: {response}")
# Delete forest operation
response = client.delete_forest_operation(forest_id)
print(f"Subcompartment deleted successfully: {response}")
License
This library is freely provided for use within the Sintetic project
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 sintetic_library-0.5.2.tar.gz.
File metadata
- Download URL: sintetic_library-0.5.2.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52f0b02b10aea77487eb678a81dcddcdf364ca946e4aaffe79a225c73995ae48
|
|
| MD5 |
5a3d5329ffa72c27d964f084718e0d47
|
|
| BLAKE2b-256 |
ca68b0d42cd416714dbe0ba7e999a2ddbe28365dcf529d2368568571e9682ff8
|
File details
Details for the file sintetic_library-0.5.2-py3-none-any.whl.
File metadata
- Download URL: sintetic_library-0.5.2-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d23afedd0f878a72c6e8d6768c4d3a9249e4fe1c016d4487e256fa669dde5b8
|
|
| MD5 |
44b2854f1c7120e93b6760595aa47765
|
|
| BLAKE2b-256 |
5e6853b58026e13c7827335e4b01a810317fddb8d7853a444d6862b5bf54d6ad
|