Load the required libraries:

In [ ]:
import openeo
import logging
import geojson


Connecting and authentication is explained here:


In [ ]:
session = openeo.connect("openeo-dev.vito.be").authenticate_oidc("egi")

Description on how to use the cropcalendar service

"summary": "CropCalendar code used to automatically predict harvest dates", "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",

Required parameters:

  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", e.g. "2019-05-06", "2021-04-30"
  2. "gjson_path" (optional):"Path to a geojson file" e.g. "/data/users/Public/herdem/geoms.gjson"

  3. "gjson" (optional), "GeoJson object" (loaded geometry collection of your fields)

You have to use either parameter 2 or 3

Define input parameters

In [ ]:
time_range = "2019-05-06", "2019-10-30"
gjson_path = "geoms.gjson"
with open("geoms.gjson") as f:
   gjson = geojson.load(f)

Option 1 for running (Terrascope public drive mandatory)

Create datacube in case the gjson path will be used for running the process

In [ ]:
calendar = session.datacube_from_process("CropCalendar", namespace="vito", time_range=time_range ,gjson = gjson)

Option 2 for running (no Terrascope public drive needed)

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)

In [ ]:
#calendar = session.datacube_from_process("CropCalendar", namespace="vito", time_range=time_range ,gjson = gjson)
In [ ]:

Download result

In [ ]:
job = calendar.execute_batch("harvest_prediction", out_format="json") #harvest_prediction will be stored at the same location as your notebook is stored.