<jupyter_start><jupyter_text>Delair.ai SDK TutorialIn this notebook, you will be guided to :- Create a **project**, **mission** and **survey**- Create and upload **datasets** (image, rasters, point cloud, mesh, vector and file)- Create an **annotation** and attach a graph to it  ⚠️ Make sure to create a copy of this notebook before modifying itTo do that `File > Make a Copy...`  Requirements - Delair Python SDK : `pip install python-delairstack`  You may execute this notebook one cell after the other with `Shift + Enter` For more options, explore `Cell` in the top menu bar, or read a [tutorial](https://www.dataquest.io/blog/jupyter-notebook-tutorial/)<jupyter_code>import os
from delairstack import DelairStackSDK
import getpass
platform_url = 'https://www.delair.ai'
login = input('Enter your email ')
password = <PASSWORD>('Enter your password ')
sdk = DelairStackSDK(url=platform_url, user=login, password=password)<jupyter_output><empty_output><jupyter_text>Download sample files (images, mesh, raster...) An archive `Banana.zip` containing sample files will be downloaded (if not found in the current directory).<jupyter_code>import urllib.request
import zipfile

try: working_dir
except NameError: working_dir = os.getcwd()
%cd {working_dir}

if not os.path.exists('Banana'):
    print('"Banana" folder not found')
    if not os.path.exists('Banana.zip'):
        print('"Banana.zip" not found')
        print('Downloading it...', end=' ')
        url = 'https://delair-transfer.s3-eu-west-1.amazonaws.com/sdks/sample-data/Banana.zip'
        filename, _ = urllib.request.urlretrieve(url, 'Banana.zip')
        print('OK')

    print('Extracting "Banana.zip"...', end=' ')
    with zipfile.ZipFile(filename, 'r') as zip_ref:
        zip_ref.extractall('.')
    print('OK')
else:
    print('"Banana" folder found. No need to download it again.')
sample_path = './Banana'
%cd {sample_path}
!ls .<jupyter_output><empty_output><jupyter_text>Create the project<jupyter_code>my_project = sdk.projects.create(
    name='SDK Tutorial',
    geometry={"coordinates": [[
                [12.397750168471589,-6.0021893390703696],
                [12.39799683152841,-6.0021893390703696],
                [12.39799683152841,-6.001515644167185],
                [12.397750168471589,-6.001515644167185],
                [12.397750168471589,-6.0021893390703696]]],
              "type": "Polygon"})
print('We just created the project {!r} with id {!r}'.format(
    my_project.name, my_project.id))<jupyter_output><empty_output><jupyter_text>List the available project properties<jupyter_code>dir(my_project)<jupyter_output><empty_output><jupyter_text>Create the survey (mission + flight)<jupyter_code>my_flight, my_mission = sdk.missions.create_survey(
    name='My survey',
    coordinates=[
        [12.398218168471589,-6.002041339094632],
        [12.398506831528413,-6.002041339094632],
        [12.398506831528413,-6.0014106608166315],
        [12.398218168471589,-6.0014106608166315],
        [12.398218168471589,-6.002041339094632]],
    project=my_project.id,
    survey_date='2015-01-31T00:00:00.000Z',
    number_of_images=5)
print('We just created the mission {!r} with id {!r}'.format(
    my_mission.name, my_mission.id))<jupyter_output><empty_output><jupyter_text>Create the datasets  Image 1<jupyter_code>default_horizontal_srs_wkt = 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY\
["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],\
UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]'
image1_dataset = sdk.datasets.create_image_dataset(
  name='00001499',
  project=my_project.id,
  mission=my_mission.id,
  flight=my_flight.id,
  geometry={"type": "Point",
            "coordinates": [12.397907, -6.001604983333333]},
  horizontal_srs_wkt=default_horizontal_srs_wkt,
  width=2448,
  height=2048
)
sdk.datasets.upload_file(
  dataset=image1_dataset.id,
  component='image',
  file_path='00001499.jpg')
print('Image dataset {!r} uploaded successfully'.format(image1_dataset.name))<jupyter_output><empty_output><jupyter_text>List the available dataset properties<jupyter_code>dir(image1_dataset)<jupyter_output><empty_output><jupyter_text>Same for the other images<jupyter_code>def create_and_upload_image_dataset(filename, coords):
    dataset_name = '.'.join(filename.split('.')[:-1])  # Name is filename without extension
    dataset = sdk.datasets.create_image_dataset(
        name=dataset_name,
        project=my_project.id,
        mission=my_mission.id,
        flight=my_flight.id,
        geometry={"type": "Point",
                  "coordinates": coords},
        horizontal_srs_wkt=default_horizontal_srs_wkt,
        width=2448,
        height=2048
    )

    sdk.datasets.upload_file(
      dataset=dataset.id,
      component='image',
      file_path=filename)
    return sdk.datasets.describe(dataset=dataset.id)
image2_dataset = create_and_upload_image_dataset(filename='00001500.jpg', coords=[12.397885, -6.001729])
image3_dataset = create_and_upload_image_dataset(filename='00001501.jpg', coords=[12.397861, -6.001856])
image4_dataset = create_and_upload_image_dataset(filename='00001502.jpg', coords=[12.397843983333333, -6.001977])
image5_dataset = create_and_upload_image_dataset(filename='00001503.jpg', coords=[12.39784, -6.0021])<jupyter_output><empty_output><jupyter_text>Complete the survey upload*Otherwise the upload progression will still be visible on the platform*<jupyter_code>sdk.missions.complete_survey_upload(flight=my_flight.id)<jupyter_output><empty_output><jupyter_text>Create the raster datasets  Orthomosaic<jupyter_code>ortho_dataset = sdk.datasets.create_raster_dataset(
  name='Orthomosaic',
  project=my_project.id,
  mission=my_mission.id,
  dataset_format='geotiff',
  categories=['orthomosaic'])

sdk.datasets.upload_file(
  dataset=ortho_dataset.id,
  component='raster',
  file_path='Orthomosaic.tif')<jupyter_output><empty_output><jupyter_text>DSM (Digital Surface Model)<jupyter_code>dsm_dataset = sdk.datasets.create_raster_dataset(
  name='DSM',
  project=my_project.id,
  mission=my_mission.id,
  dataset_format='geotiff',
  categories=['dsm'])

sdk.datasets.upload_file(
  dataset=dsm_dataset.id,
  component='raster',
  file_path='DSM.tif')<jupyter_output><empty_output><jupyter_text>Create the point cloud dataset<jupyter_code>pcl_dataset = sdk.datasets.create_pcl_dataset(
  name='PointCloud',
  project=my_project.id,
  mission=my_mission.id,
  dataset_format='las')

sdk.datasets.upload_file(
  dataset=pcl_dataset.id,
  component='pcl',
  file_path='Point Cloud.las')<jupyter_output><empty_output><jupyter_text>Create the mesh dataset<jupyter_code>mesh_dataset = sdk.datasets.create_mesh_dataset(
  name='Mesh',
  project=my_project.id,
  mission=my_mission.id,
  dataset_format='obj',
  texture_count=1)

sdk.datasets.upload_file(
  dataset=mesh_dataset.id,
  component='mesh',
  file_path='Model.obj')

sdk.datasets.upload_file(
  dataset=mesh_dataset.id,
  component='material',
  file_path='Model.mtl')

sdk.datasets.upload_file(
  dataset=mesh_dataset.id,
  component='texture',
  file_path='Model_0.jpg')<jupyter_output><empty_output><jupyter_text>Create the vector dataset<jupyter_code>vector_dataset = sdk.datasets.create_vector_dataset(
    name='ContoursLines',
    project=my_project.id,
    mission=my_mission.id,
    dataset_format='geojson')

sdk.datasets.upload_file(
  dataset=vector_dataset.id,
  component='vector',
  file_path='Contours.geojson')<jupyter_output><empty_output><jupyter_text>Create an annotation<jupyter_code>my_annotation = sdk.annotations.create(
   project=my_project.id,
   mission=my_mission.id,
   geometry={
       "type": "Point",
       "coordinates": [12.397626065125216, -6.001589143208957]
   },
   name='New annotation',
   type='2d',
   icon=sdk.annotations.Icons.CONVEYOR
)<jupyter_output><empty_output><jupyter_text>The end<jupyter_code>from IPython.display import Markdown, display
from urllib.parse import urljoin

def printmd(string):
    display(Markdown(string))

printmd('### 💥 You can have a look at your project on the platform')
project_url = urljoin(platform_url, 'app/project/{}/view;leftPanel=layers'.format(my_project.id))
print(project_url)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13254025474645517, 'fraction_numerical': 0.07438115837539053, 'mean_word_length': 5.487139516757599, 'pattern_counts': {'":': 8, '<': 66, '<?xml version=': 0, '>': 67, 'https://': 3, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '16', 'dir': 'jupyter-structured-clean-dedup', 'id': '523833', 'license': 'MIT', 'n_tokens_mistral': 3342, 'n_tokens_neox': 2938, 'n_words': 463, 'path': 'notebooks/getting_started.ipynb', 'repo_name': 'delair-ai/python-delairstack', 'size': '8327'}