# CropSAR Service

**CropSAR** utilizes Sentinel-1 radar observations alongside Sentinel-2 data. It enables continuous monitoring of vegetation properties. This approach includes vegetation information for locations obscured by clouds for Sentinel-2 data. It benefits operational agricultural monitoring, allowing observation of the entire crop growth cycle, including critical developmental changes.

The Sentinel-1 σ₀ backscatter signal provides insights into vegetation structure and soil moisture content. Figure 1 illustrates this correlation.

![](https://docs.terrascope.be/Developers/WebServices/fig/CropSAR_S1_S2.png)

***Figure 1:** Sentinel-2 NDVI observations over a winter wheat field and the corresponding Sentinel-1 backscatter signature. While both measurements are completely different, the correlation between optical and radar is clearly visible, especially during the growing season ([van Tricht et al., 2018](https://doi.org/10.3390/rs10101642))*.

For a more detailed introduction to CropSAR, including its working principles and added value, refer to [this blog](https://blog.vito.be/remotesensing/cropsar2019).

> **NOTE:**
>
> CropSAR aims to deliver augmented Sentinel-1 and Sentinel-2 vegetation indices tailored for individual agricultural fields. While it can be requested for larger areas, its added value may be limited. Additionally, processing time for generating results at this scale can be significant.

## Use the CropSAR Service

While detailed API documentation for the CropSAR webservice is available [here](https://cropsar.vito.be/api/docs/), the following examples demonstrate how to use the CropSAR service in Python. User can directly access the [CropSAR](https://portal.terrascope.be/catalogue/app-details/10) to run it in a [openEO web editor](https://editor.openeo.org/?server=openeo.terrascope.be).

### Using as EOplaza Service

An example of accessing the CropSAR service for FAPAR is shown below; for a detailed explanation of using the EOplaza service, refer to the page [here](https://docs.terrascope.be/Developers/EOplaza/Execute.llms.md).

``` python

# import necessary packages
import openeo

# connect with the backend
eoconn = openeo.connect(
        "openeo.terrascope.be"
        ).authenticate_oidc()

# Setup process parameters
aoi = {
        "type": "Polygon",
        "coordinates": [
          [
            [
              5.179324150085449,
              51.2498689148547
            ],
            [
              5.178744792938232,
              51.24672597710759
            ],
            [
              5.185289382934569,
              51.24504696935156
            ],
            [
              5.18676996231079,
              51.245342479161295
            ],
            [
              5.187370777130127,
              51.24918393390799
            ],
            [
              5.179324150085449,
              51.2498689148547
            ]
          ]
        ]
      }
date = ["2021-10-01", "2021-10-10"]

biopar = "FAPAR"

# Create a processing graph from the CropSAR process using an active openEO connection
cropsar = eoconn.datacube_from_process(
          process_id='cropsar1d',
          namespace="vito",
          geometry=aoi,
          startdate=date[0],
          enddate=date[1],
          output=biopar
      )

# Execute the process graph
cropsar.download("Fapar.json")
```

### Using requests module

The following example retrieves a basic CropSAR timeseries for fAPAR:

``` python

import requests

geometry = {
    "type": "Polygon",
    "coordinates": [[
        [5.1033251301854055, 51.28261016933643],
        [5.1031970304595395, 51.28309115665867],
        [5.104381444596166,  51.283690689238],
        [5.103852870907387,  51.28270508250087],
        [5.1033251301854055, 51.28261016933643]
    ]]
}

response = requests.post(url='https://cropsar.vito.be/api/v1.0/cropsar/',
                         params={'product': 'S2_FAPAR',
                                 'start':   '2019-01-01',
                                 'end':     '2019-12-31',
                                 'crs':     'epsg:4326',
                                 'source':  'probav-mep'},
                         json=geometry)

response.raise_for_status()

data = response.json()

import pandas

df = pandas.DataFrame.from_dict(data, orient='index')
df.index = pandas.to_datetime(df.index)
df.data = pandas.to_numeric(df.data, errors='coerce')
df.plot(figsize=(10, 5))
df
```

User can use either of the above methods to access the CropSAR service.
