{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# ExactEarth AIS Historical Vessel Tracks\n", "\n", "The ExactEarth AIS HVT block provides access to historical data tracks of the Automatic Identification System (AIS). The block queries the Exact Earth historical vessel tracks API and provides ship track linestring geometries and associated metadata e.g. ship name, cargo, destination port, etc\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/c1678e74-70b5-47a7-b8fe-caebc4f470d9) and [Documentation](https://docs.up42.com/up42-blocks/data/ais-hvt.html)." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "import up42" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2021-03-11 11:03:52,038 - Got credentials from config file.\n", "2021-03-11 11:03:52,639 - Authentication with UP42 successful!\n", "2021-03-11 11:03:52,640 - Logging disabled - use up42.settings(log=True) to reactivate.\n" ] } ], "source": [ "up42.authenticate(cfg_file=\"config.json\")\n", "up42.settings(log=False)\n", "project = up42.initialize_project()" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "100%|██████████| 1/1 [00:00<00:00, 2.71it/s]\n" ] } ], "source": [ "# Construct workflow\n", "workflow = project.create_workflow(name=\"AIS tracks\", use_existing=True)\n", "#print(up42.get_blocks(basic=True))\n", "input_tasks = [\"ais-hvt\"]\n", "workflow.add_workflow_tasks(input_tasks)" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [], "source": [ "# Define the aoi and input parameters of the workflow to run it.\n", "aoi = {\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"properties\":{},\n", " \"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[-5.370973,36.115663],\n", " [-5.348018,36.115663],\n", " [-5.355756,36.141326],\n", " [-5.3598,36.147976],\n", " [-5.370531,36.148606],\n", " [-5.370973,36.115663]]]}}]}\n", "input_parameters = workflow.construct_parameters(geometry=aoi, \n", " geometry_operation=\"bbox\")\n", "input_parameters[\"ais-hvt:1\"][\"time\"] = \"2021-02-01T10:00:00+00:00/2021-02-01T23:59:59+00:00\"" ] }, { "cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'ais-hvt:1': {'blockConsumption': {'resources': {'unit': 'SQUARE_KM',\n", " 'min': 7.568521,\n", " 'max': 7.568521},\n", " 'credit': {'min': 38, 'max': 38}},\n", " 'machineConsumption': {'duration': {'min': 0, 'max': 0},\n", " 'credit': {'min': 1, 'max': 1}}}}" ] }, "execution_count": 35, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Price estimation\n", "workflow.estimate_job(input_parameters)" ] }, { "cell_type": "code", "execution_count": 36, "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": 47, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Gibraltar: 1 tracks detected\n" ] }, { "data": { "text/html": [ "
Make this Notebook Trusted to load map: File -> Trust Notebook
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "#for aoi, job in zip(aois, jobs):\n", "tracks=job.get_results_json(as_dataframe=True)\n", "print(f\"Gibraltar: {tracks.shape[0]} tracks detected\")\n", "display(job.map_results())" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "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.6" } }, "nbformat": 4, "nbformat_minor": 4 }