This overview of the most important functions repeats the previous 30-seconds-example, but in more detail and shows additional functionality and alternative steps.
import up42
up42.authenticate(project_id=12345, project_api_key=12345)
#up42.authenticate(cfg_file="config.json")
project = up42.initialize_project()
project
Get information about the available blocks to later construct your workflow.
up42.get_blocks(basic=True)
You can either create a new workflow, use project.get_workflows() to get all existing workflows within the project, or access an exisiting workflow directly via its workflow_id.
Example: Sentinel 2 streaming & sharpening filter
# Create a new, empty workflow.
workflow = project.create_workflow(name="30-seconds-workflow", use_existing=False)
workflow
# Add workflow tasks - simple version. See above .get_blocks() result.
input_tasks= ["a2daaab4-196d-4226-a018-a810444dcad1", "4ed70368-d4e1-4462-bef6-14e768049471"]
workflow.add_workflow_tasks(input_tasks=input_tasks)
# Alternative: Add workflow tasks - complex version, gives you more control about the block connections.
input_tasks = [
{
"name": "sobloo-s2-l1c-aoiclipped:1",
"parentName": None,
"blockId": "a2daaab4-196d-4226-a018-a810444dcad1"
},
{
"name": "sharpening:1",
"parentName": "sobloo-s2-l1c-aoiclipped:1",
"blockId": "4ed70368-d4e1-4462-bef6-14e768049471"
}
]
workflow.add_workflow_tasks(input_tasks=input_tasks)
# Check the added tasks.
workflow.get_workflow_tasks(basic=True)
#workflow.get_jobs()
# Alternative: Get all existing workflows within the project.
all_workflows = project.get_workflows()
workflow = all_workflows[0]
workflow
# Alternative: Directly access the existing workflow the id (has to exist within the accessed project).
UP42_WORKFLOW_ID="7fb2ec8a-45be-41ad-a50f-98ba6b528b98"
workflow = up42.initialize_workflow(workflow_id=UP42_WORKFLOW_ID)
workflow
There are multiple ways to select an aoi, you can:
aoi = [13.375966, 52.515068, 13.378314, 52.516639]
aoi = workflow.read_vector_file("data/aoi_berlin.geojson", as_dataframe=True)
aoi.head(1)
#aoi = workflow.get_example_aoi(location="Berlin")
#aoi
#workflow.draw_aoi()
There are also multiple ways to construct the workflow input parameters, you can:
workflow.get_parameters_info()
input_parameters = {
"sobloo-s2-l1c-aoiclipped:1": {
"bbox": [13.375966, 52.515068, 13.378314, 52.516639],
"ids": None,
"time": "2018-01-01T00:00:00+00:00/2020-12-31T23:59:59+00:00",
"limit": 1,
"zoom_level": 14,
"time_series": None,
"max_cloud_cover": 30
},
"sharpening:1": {
"strength": "medium"
}
}
input_parameters = workflow.construct_parameters(geometry=aoi, geometry_operation="bbox", limit=1)
input_parameters
# Further update the input_parameters manually
input_parameters["sobloo-s2-l1c-aoiclipped:1"].update({"max_cloud_cover":60})
input_parameters
# Run a test job to query data availability and check the configuration.
test_job = workflow.test_job(input_parameters=input_parameters, track_status=True)
test_results = test_job.get_results_json()
print(test_results)
# Run the actual job.
job = workflow.run_job(input_parameters=input_parameters, track_status=True)
# Download job result (default downloads to Desktop). Only works after download is finished.
results_fp = job.download_results()
job.plot_results()
job.map_results()