{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 30 seconds example\n", "\n", "In this example a **new workflow** consisting of [**Sentinel-2 L2A data**](https://marketplace.up42.com/block/c4cb8913-2ef3-4e82-a426-65ea8faacd9a)\n", "and [**Sharpening Filter**](https://marketplace.up42.com/block/e374ea64-dc3b-4500-bb4b-974260fb203e) 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 L2A Visual (GeoTIFF)\", \"Sharpening Filter\"]\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[\"esa-s2-l2a-gtiff-visual: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))" ] }, { "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 }