{ "cells": [ { "cell_type": "markdown", "id": "ecd778cf", "metadata": {}, "source": [ "Load the required libraries:" ] }, { "cell_type": "code", "execution_count": null, "id": "62bb8035", "metadata": {}, "outputs": [], "source": [ "import openeo\n", "import logging\n", "import geojson" ] }, { "cell_type": "markdown", "id": "d52888ce", "metadata": {}, "source": [ "## Connecting\n", "Connecting and authentication is explained here:\n", "\n", "https://docs.terrascope.be/#/Developers/WebServices/OpenEO/OpenEO?id=logging-in" ] }, { "cell_type": "code", "execution_count": null, "id": "022e0096", "metadata": {}, "outputs": [], "source": [ "session = openeo.connect(\"openeo-dev.vito.be\").authenticate_oidc(\"egi\")" ] }, { "cell_type": "markdown", "id": "adb55ca9", "metadata": {}, "source": [ "## Description on how to use the cropcalendar service\n", "\n", "\n", "\"summary\": \"CropCalendar code used to automatically predict harvest dates\",\n", "\"description\": \"CropCalendar harvest date prediction for all given input geometries. Only one harvest date (the first observed) is predicted within the given time_range. Therefore, for harvest date prediction over a longer period just subidivde the time_range into smaller parts. The required input is a loaded geojson file (featurecollection) or the path (on Public Terrascope drive) to the geojson file. The returned output is the original geojson file with an additional property, which contains the predicted harvest dates. In case no harvest date could be predicted for a specific geometry, a nodata value will be assigned to that field. Restriction: The input geometries should be 10m inwards buffered fromm its boundaries, otherwise the harvest date prediction reliability might drop\",\n", "\n", "Required parameters:\n", "1. \"time_range\": \"A time range for which to compute the harvest date. The time range should span more than 2 months and preferably centered around the expected harvest date\",\n", "e.g. \"2019-05-06\", \"2021-04-30\"\n", "2. \"gjson_path\" (optional):\"Path to a geojson file\" e.g. \"/data/users/Public/herdem/geoms.gjson\"\n", "\n", "3. \"gjson\" (optional), \"GeoJson object\" (loaded geometry collection of your fields)\n", "\n", "You have to use either parameter 2 or 3" ] }, { "cell_type": "markdown", "id": "f42e2175", "metadata": {}, "source": [ "## Define input parameters" ] }, { "cell_type": "code", "execution_count": null, "id": "06606da7", "metadata": {}, "outputs": [], "source": [ "time_range = \"2019-05-06\", \"2019-10-30\"\n", "gjson_path = \"geoms.gjson\"\n", "with open(\"geoms.gjson\") as f:\n", " gjson = geojson.load(f)" ] }, { "cell_type": "markdown", "id": "3d4c532a", "metadata": {}, "source": [ "## Option 1 for running (Terrascope public drive mandatory)\n", "Create datacube in case the gjson path will be used for running the process" ] }, { "cell_type": "code", "execution_count": null, "id": "bdf8fd8d", "metadata": {}, "outputs": [], "source": [ "calendar = session.datacube_from_process(\"CropCalendar\", namespace=\"vito\", time_range=time_range ,gjson = gjson)" ] }, { "cell_type": "markdown", "id": "b0d59877", "metadata": {}, "source": [ "## Option 2 for running (no Terrascope public drive needed)\n", "Create datacube in case the loaded geojson object will be used for running the process (in case you don't have a Terrascope Public drive)\n" ] }, { "cell_type": "code", "execution_count": null, "id": "c5615aef", "metadata": {}, "outputs": [], "source": [ "#calendar = session.datacube_from_process(\"CropCalendar\", namespace=\"vito\", time_range=time_range ,gjson = gjson)" ] }, { "cell_type": "code", "execution_count": null, "id": "606d8040", "metadata": {}, "outputs": [], "source": [ "calendar.graph" ] }, { "cell_type": "markdown", "id": "fcf232e7", "metadata": {}, "source": [ "## Download result" ] }, { "cell_type": "code", "execution_count": null, "id": "e528d547", "metadata": {}, "outputs": [], "source": [ "job = calendar.execute_batch(\"harvest_prediction\", out_format=\"json\") #harvest_prediction will be stored at the same location as your notebook is stored." ] } ], "metadata": { "kernelspec": { "display_name": "python36", "language": "python", "name": "python36" }, "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.6.8" } }, "nbformat": 4, "nbformat_minor": 5 }