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.
A new workflow is created and filled with tasks (Sentinel-2 data, Land-Surface-Temperature). The area of interest and workflow parameters are defined. After running the job, the results are downloaded and visualized.
# Create a new, empty workflow.
workflow = project.create_workflow(name="30-seconds-workflow", use_existing=False)
workflow
# Add workflow tasks
input_tasks = ["Sentinel-2 Level 2 (BOA) AOI clipped", "Land Surface Temperature Estimation"]
workflow.add_workflow_tasks(input_tasks=input_tasks)
# Check the added tasks.
workflow.get_workflow_tasks(basic=True)
# 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 = up42.read_vector_file("data/aoi_berlin.geojson", as_dataframe=True)
aoi.head(1)
#aoi = up42.get_example_aoi(location="Berlin")
#aoi
#up42.draw_aoi()
There are also multiple ways to construct the workflow input parameters, you can:
workflow.get_parameters_info()
input_parameters = workflow.construct_parameters(geometry=aoi, geometry_operation="bbox", limit=1)
# Further update the input_parameters manually
input_parameters["sentinelhub-s2-aoiclipped:1"].update({"max_cloud_cover":10})
input_parameters
workflow.estimate_job(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(figsize=(6,6), bands=[1], cmap="YlOrBr")
#job.map_results(bands=[1])