Eo-learn tutorial/documentation for preprocessing Sentinel-1 data?

Hello there. Pardon me if you find it a very basic question. I am a newbie when it comes to eo-learn. I’m wondering if there is any tutorial or any step-by-step guide for using eo-learn library for crop-type mapping using Sentinel-1 data. I’ve seen plenty of tutorials so far but all i’m seeing are using Sentinel-2 including the documentation of eo-learn itself. I specifically want to learn how to preprocess Sentinel-1 (using my own data from local storage) for machine learning application. I hope somebody can help me through this. Just dropping any tutorial links that uses Sentinel-1 will be helpful.

Hi @reyrey

In principle you can try with the same examples as for using Sentinel-2, but inputting S-1 data. That being said, the preprocessing of Sentinel-1 data is usually quite important, and different backscatter coefficients are proposed for different applications, in agriculture typically a ratio of VV/VH.

Using Sentinel-Hub, you can “skip” preprocessing, as Sentinel-Hub can do it for you: you can request orthorectified, radiometric terrain-corrected product with applied Lee speckle filtering. In eo-learn, you can get this using the following snippet:

evalscript = """
// your evalscript
"""

card4l_processing = {
    "backCoeff": "GAMMA0_TERRAIN",
    "orthorectify": True,
    "demInstance": "COPERNICUS",
    "downsampling": "BILINEAR",
    "upsampling": "BILINEAR"
}

get_s1_asc = SentinelHubEvalscriptTask(
    features={
        FeatureType.DATA: {'VV', 'VH', 'ANGLE'},
        FeatureType.MASK: {'MASK'},
        FeatureType.META_INFO: {'card4l_metadata'}
    },
    evalscript=evalscript,
    data_collection=DataCollection.SENTINEL1_IW_ASC,
    resolution=RESOLUTION,
    time_difference=dt.timedelta(minutes=TIME_DELTA),
    aux_request_args={'processing': card4l_processing},
    max_threads=MAX_THREADS,
    config=sh_config
)

The evalscript can be simple (e.g. just retrieving backscatter coefficients), or something more elaborate (e.g. RVI).

1 Like

Hi @batic

Thank you so much for this. Very appreciated.

But i also want if you have some sample code on how to import data (sentinel-1) from local storage? Specifically the ImportFromTiffTask.

Also, what is the proper arrangement of the data (.tiff images) when importing locally? Do they have to be separated in different folder by date? I also want to know if you have sample screenshots of that.

Hi @reyrey,

Here is a basic example how to use ImportFromTiffTask:

import_task = ImportFromTiff(
    (FeatureType.DATA, 'MY_FEATURE'),
    folder='./path/to/local/or/s3/folder'
)

import_task.execute(eopatch, filename='remaining/path/filename.tiff')

In this normal use case you can have tiff files in any folders you want. At initialization you specify the base path that is in common to all tiff files and at execute you can specify the remaining path with a filename.

There is also an advanced usage, where you can use filename parameter to specify either a list of multiple paths or a path pattern. In that case multiple tiff files would be loaded and joined into one EOPatch feature. This part is not that well documented though, but you can find more by checking the code.

1 Like

Hi @maleksandrov ,

Thank you so much for the quick response. This will help me a lot!

Hi @maleksandrov ,

I am trying to import Sentinel-1 .tiff files via ImportFromTiffTask but I am facing this error NoneType' object has no attribute 'to_epsg Btw, I downloaded the Sentinel-1 files via copernicus hub website. Here is the sceenshot:

Hi @reyrey,

could you check if your files are correctly georeferenced? I also recommend checking this:

import rasterio

with rasterio.open(your_file_path) as src:
    print(src.crs)  # If your images are georeferenced this shouldn't be None
    print(type(src.crs))

This is basically also what ImportFromTiffTask does in the background.

1 Like

@maleksandrov, I just checked the files and it’s not georeferenced! I will fix it real quick and try again. At least, i am now aware what is the problem. Thank you so much for the fast reply.

Hi @maleksandrov

Does eo-learn library automatically apply tiling on images to become smaller tiles?

No, any tiling has to be added by users. You can either use some large area utilities from sentinelhub-py or implement your own tiling.

1 Like

Hi @maleksandrov, thanks for answering my last question! I also want to ask

Is execution_args in workflow execution required? If yes, how to properly implement it when dealing with locally imported data?

Yes, parameter execution_args is required to initialize EOExecutor class. I recommend checking this part of the docs to see how it is constructed.

As you can see, the arguments are the execute method parameters of tasks in a workflow. This are the parameters that are supposed to be patch-specific and are different for each EOPatch.

Thank you, @maleksandrov !

Hi @maleksandrov. What does ErosionTask actually do?

Hi @reymond_m,

From the ErosionTask implementation you can see that it is a simple wrapper around skimage.morphology.binary_erosion.

1 Like