{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Global Seeps Sample\n", "\n", "This example shows how to use the Airbus Global Seeps Sample data block with the UP42 Python SDK. This block provides free sample data from the Global Seeps database in the UK region, giving information about oil seeps, ship rigs etc. It demonstrates the application of the paid Global Seeps block, which can be used globally.\n", "\n", "In the example, the workflow, the area of interest and the workflow parameters are defined. After running the job, the results are downloaded and visualized. For more information, refer to the block's [UP42 Marketplace page](https://marketplace.up42.com/block/dfc5d74f-d1e3-4e35-8c67-b36fd8cfe14e) and [Documentation](https://docs.up42.com/up42-blocks/data/airbus-globalseeps-sample.html)." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import up42" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2021-03-11 12:54:45,785 - Authentication with UP42 successful!\n", "2021-03-11 12:54:46,521 - Initialized Project(name: sdk-test, project_id: 6df5f59e-706d-4102-a136-b83b87c6006c, description: , createdAt: 2021-03-05T14:27:13.550603Z)\n" ] } ], "source": [ "up42.authenticate(project_id=\"12345\", \n", " project_api_key=\"12345\")\n", "project = up42.initialize_project()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2021-03-11 12:54:47,838 - Updated project settings: [{'name': 'JOB_QUERY_MAX_AOI_SIZE', 'value': '1000'}, {'name': 'MAX_CONCURRENT_JOBS', 'value': '10'}, {'name': 'JOB_QUERY_LIMIT_PARAMETER_MAX_VALUE', 'value': '10'}]\n" ] } ], "source": [ "# Update the project aoi size limit to 1000 sqkm to able to query bigger areas\n", "project.update_project_settings(max_aoi_size=1000)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2021-03-11 12:54:47,844 - Getting existing workflows in project ...\n", "2021-03-11 12:54:48,379 - Got 4 workflows for project 6df5f59e-706d-4102-a136-b83b87c6006c.\n", "100%|██████████| 4/4 [00:02<00:00, 1.53it/s]\n", "2021-03-11 12:54:51,012 - Using existing workflow: Global Seeps Sample Example - 0788eec1-3d43-48e5-ae18-7e002ac7be88\n" ] } ], "source": [ "# Construct the workflow\n", "workflow = project.create_workflow(name=\"Global-Seeps-Sample Example\", use_existing=True)\n", "\n", "input_tasks = [\"Global Seeps Sample\"]\n", "workflow.add_workflow_tasks(input_tasks)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "# We select an area off the east-coast of England\n", "aoi_bbox = [0.330963, 53.960126, 0.65918, 54.106918]\n", "# Can also use up42.draw_aoi(), up42.read_vector_file(), provide a FeatureCollection, GeoDataFrame etc." ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'airbus-globalseeps-sample:1': {'object_type': ['Scenes',\n", " 'Ships_Rigs',\n", " 'Slick_Points',\n", " 'Slick_Outlines'],\n", " 'limit': 1,\n", " 'time': '2018-01-01T00:00:00Z/2021-12-31T23:59:59Z',\n", " 'bbox': [0.330963, 53.960126, 0.65918, 54.106918]}}" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Define the aoi and input parameters of the workflow to run it.\n", "input_parameters = workflow.construct_parameters(geometry=aoi_bbox, \n", " geometry_operation=\"bbox\", \n", " start_date=\"2018-01-01\",\n", " end_date=\"2021-12-31\",\n", " limit=1)\n", "input_parameters" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2021-03-11 12:55:08,500 - Estimated: 1-1 Credits, Duration: 715-2462 min.\n" ] }, { "data": { "text/plain": [ "{'airbus-globalseeps-sample:1': {'blockConsumption': {'resources': {'unit': 'MEGABYTE',\n", " 'min': 0.005,\n", " 'max': 0.03},\n", " 'credit': {'min': 0, 'max': 0}},\n", " 'machineConsumption': {'duration': {'min': 42935, 'max': 147750},\n", " 'credit': {'min': 1, 'max': 1}}}}" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Price estimation\n", "workflow.estimate_job(input_parameters)" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2021-03-11 13:05:16,156 - Selected input_parameters: {'airbus-globalseeps-sample:1': {'object_type': ['Scenes', 'Ships_Rigs', 'Slick_Points', 'Slick_Outlines'], 'limit': 1, 'time': '2018-01-01T00:00:00Z/2021-12-31T23:59:59Z', 'bbox': [0.330963, 53.960126, 0.65918, 54.106918]}}\n", "2021-03-11 13:05:18,963 - Created and running new job: 530f4103-1482-43e4-94e8-ebd99b399068.\n", "2021-03-11 13:05:19,576 - Tracking job status continuously, reporting every 30 seconds...\n", "2021-03-11 13:05:46,846 - Job finished successfully! - 530f4103-1482-43e4-94e8-ebd99b399068\n" ] } ], "source": [ "# Run the workflow and download the results.\n", "job = workflow.run_job(input_parameters=input_parameters, track_status=True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "job.download_results()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "When downloading and visualizing the results, we can see multiple ship rig point geometries with their respective properties." ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Make this Notebook Trusted to load map: File -> Trust Notebook
" ], "text/plain": [ "" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "job.map_results()" ] }, { "cell_type": "markdown", "metadata": {}, "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 }