{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 30 seconds example\n", "\n", "In this example a **new workflow** consisting of [**Sentinel-2 data**](https://marketplace.up42.com/block/018dfb34-fc19-4334-8125-14fd7535f979)\n", "and [**Land-Surface-Temperature**](https://marketplace.up42.com/block/34767300-5caf-472b-a684-a351212b5c14) is created.\n", "The area of interest and workflow parameters are defined. After **running the job**, \n", "the results are **downloaded** and visualized." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import up42" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "up42.authenticate(project_id=\"12345\", \n", " project_api_key=\"67890\")\n", "project = up42.initialize_project()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Construct workflow\n", "workflow = project.create_workflow(name=\"30-seconds-workflow\", use_existing=True)\n", "#print(up42.get_blocks(basic=True))\n", "input_tasks = [\"Sentinel-2 Level 2 (BOA) AOI clipped\", \"Land Surface Temperature Estimation\"]\n", "workflow.add_workflow_tasks(input_tasks)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Define the aoi and input parameters of the workflow to run it.\n", "# Can also use up42.draw_aoi(), up42.read_vector_file(), provide a FeatureCollection, GeoDataFrame etc.\n", "aoi = up42.get_example_aoi(as_dataframe=True)\n", "input_parameters = workflow.construct_parameters(geometry=aoi, \n", " geometry_operation=\"bbox\", \n", " start_date=\"2018-01-01\",\n", " end_date=\"2020-12-31\",\n", " limit=1)\n", "input_parameters[\"sentinelhub-s2-aoiclipped:1\"].update({\"max_cloud_cover\":5})" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Price estimation\n", "workflow.estimate_job(input_parameters)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Run a test job to query data availability and check the configuration.\n", "test_job = workflow.test_job(input_parameters, track_status=True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Run the actual job.\n", "job = workflow.run_job(input_parameters, track_status=True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "job.download_results()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "job.plot_results(figsize=(6,6), bands=[1], cmap=\"YlOrBr\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#job.map_results(bands=[1])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "up42-py", "language": "python", "name": "up42-py" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.3" } }, "nbformat": 4, "nbformat_minor": 4 }