<jupyter_start><jupyter_text>Distances API Example Run this example in [Colab](https://colab.research.google.com/github/SignalOceanSdk/SignalSDK/blob/master/docs/examples/jupyter/DistancesAPI/QuickStartDistancesAPI.ipynb)  SetupInstall the Signal Ocean SDK:```pip install signal-ocean```Set your subscription key acquired here: https://apis.signalocean.com/profile<jupyter_code>pip install signal-ocean
signal_ocean_api_key = '' #replace with your subscription key<jupyter_output><empty_output><jupyter_text>Calculate a distance over 2 portsCreate a connections towards distances API.Then call the distance API to get a distance between Fuijairah and Singapore for a VLCC vessel (corresponding restrictions applied)<jupyter_code>from signal_ocean import Connection
from signal_ocean.distances import DistancesAPI, VesselClassFilter, PortFilter, LoadingCondition

connection = Connection(api_key=signal_ocean_api_key)
distances_api = DistancesAPI(connection)

load_port = distances_api.get_ports(PortFilter(name_like='Fujairah'))[0]
discharge_port = distances_api.get_ports(PortFilter(name_like='Singapore'))[0]

vessel_class = distances_api.get_vessel_classes(VesselClassFilter(name_like='vlcc'))[0]
distanceInNM = distances_api.get_port_to_port_distance(vessel_class, LoadingCondition.BALLAST, load_port, discharge_port)

print(distanceInNM)<jupyter_output>3302.86<jupyter_text>Create a distance matrixFind distance in NM for a Aframax vessel from Trieste to every available port. Persist the output in an excel file.<jupyter_code>distancesFromTriesteDictionary = {}

port_from = distances_api.get_ports(PortFilter(name_like='Trieste'))[0]
ports_to_get_distance = ['Rotterdam','Singapore','Lome','Long Beach','Galveston','Pazflor','Bonny','Ras Tanura','Houston','Escravos']

for port_to_filter in ports_to_get_distance:
    port_to = distances_api.get_ports(PortFilter(name_like=port_to_filter))[0]
    distanceInNM = distances_api.get_port_to_port_distance(vessel_class, LoadingCondition.BALLAST, port_from, port_to)
    distancesFromTriesteDictionary[port_to.name] = float(distanceInNM)
import pandas as pd
import openpyxl

df = pd.DataFrame(data=distancesFromTriesteDictionary, index=[0])
pd.options.display.float_format = '{:,.2f}'.format
df = (df.T)
df.to_excel('simpleDistanceMatrix_Trieste_Aframax_Ballast.xlsx')
df<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup