#!/usr/bin/env python # coding: utf-8 # # ExactEarth AIS Historical Vessel Tracks # # 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 # # 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). # In[6]: import up42 # In[7]: up42.authenticate(cfg_file="config.json") up42.settings(log=False) project = up42.initialize_project() # In[9]: # Construct workflow workflow = project.create_workflow(name="AIS tracks", use_existing=True) #print(up42.get_blocks(basic=True)) input_tasks = ["ais-hvt"] workflow.add_workflow_tasks(input_tasks) # In[29]: # Define the aoi and input parameters of the workflow to run it. aoi = {"type":"FeatureCollection","features":[{"type":"Feature","properties":{}, "geometry":{"type":"Polygon","coordinates":[[[-5.370973,36.115663], [-5.348018,36.115663], [-5.355756,36.141326], [-5.3598,36.147976], [-5.370531,36.148606], [-5.370973,36.115663]]]}}]} input_parameters = workflow.construct_parameters(geometry=aoi, geometry_operation="bbox") input_parameters["ais-hvt:1"]["time"] = "2021-02-01T10:00:00+00:00/2021-02-01T23:59:59+00:00" # In[35]: # Price estimation workflow.estimate_job(input_parameters) # In[36]: # Run the actual job. job = workflow.run_job(input_parameters, track_status=True) # In[ ]: job.download_results() # In[47]: #for aoi, job in zip(aois, jobs): tracks=job.get_results_json(as_dataframe=True) print(f"Gibraltar: {tracks.shape[0]} tracks detected") display(job.map_results()) # In[ ]: