Understanding fis_data_to_dataframe results

I’m trying to use fis_request in order to get mean NDVI as time series for different polygons in one shapefile layer.
In the example and also I have gotten table that looks like this:

>>channel  date	       min	max	mean	stDev
72	0	2020-01-05	0.0	1.0	0.642578	0.345789
71	0	2020-01-10	0.0	1.0	0.618322	0.346922
70	0	2020-01-15	0.0	1.0	0.714291	0.307972
69	0	2020-01-20	0.0	1.0	0.631003	0.333117
68	0	2020-01-25	0.0	1.0	0.723431	0.329044
....
223 3       2020-12-10      1.0   1.0  1.000000  0.000000 


I’m a little bit confused regard this results- what are the channels? how do the numbers in the index chosen? how can I get this data per polygon ?(as I understnd this is for the whole bbox?) ? is there any way to udnerstand which row belongs to each polygon?

This is how I got this results:

fis_request = FisRequest(
    data_collection=DataCollection.SENTINEL2_L2A,
    layer='NDVI',
    geometry_list=[bbox],
    time=time_interval,
    resolution='60m',
    data_folder='./data',
    config=config
)

def fis_data_to_dataframe(fis_data):
    """ Creates a DataFrame from list of FIS responses
    """
    COLUMNS = ['channel', 'date', 'min', 'max', 'mean', 'stDev']
    data = []

    for fis_response in fis_data:
        for channel, channel_stats in fis_response.items():
            for stat in channel_stats:
                row = [int(channel[1:]), iso_to_datetime(stat['date'])]

                for column in COLUMNS[2:]:
                    row.append(stat['basicStats'][column])

                data.append(row)

    return pd.DataFrame(data, columns=COLUMNS).sort_values(['channel', 'date'])


df = fis_data_to_dataframe(fis_data)

df

“channels” are related to the “output” in the EVALSCRIPT.
E.g. if you have only one variable (return [ndvi]), you will have only one channel (C0). If you however want to get several indices at the same time (return [var1, var2, var3]), you will get more channels (C0=var1, C1 = var2, C2 = var3).

You can execute FIS request for a polygon geometry (not just BBOX). You will however have to do one request for each polygon if you want to have results separated by them.

Thank you for your answer!
There is still something that I odn’t understand regard it, because I haven’t used EVALSCRIPT in order to get those images , I have only defined NDVI in “layer”, but I still get those 3 mysterious channels.

I use this function to calculate the bbox:

def get_bbox_from_shape(shape,resolution):
    minx, miny, maxx, maxy = shape.geometry.total_bounds
    bbox_coords_wgs84=[minx, miny, maxx, maxy]
    bbox = BBox(bbox=bbox_coords_wgs84, crs=CRS.WGS84)
    bbox_size = bbox_to_dimensions(bbox, resolution=resolution)
    return bbox_size,bbox,bbox_coords_wgs84
    

and then use the fis request:

fis_request = FisRequest(
    data_collection=DataCollection.SENTINEL2_L2A,
    layer='NDVI',
    geometry_list=[bbox],
    time=time_interval,
    resolution='60m',
    data_folder='./data',
    config=config
)

so I don’t see where those channels are being added.

If I understood you correct, I could potentially add more indices by using the “layer” parameter in the fis request?

Thank you for you patient

Reut

Ah, I see. Now I understand your issue.
When using LAYER, the EVALSCRIPT is actually stored in the configuration.
Go to Configuration utility, find the appropriate configuration, then the layer and you will see what is in there.
If you are getting three channels in the FIS request, there is a large chance you are actually querying visualisation layer, where NDVI is mapped to various colors, so each channel is representation of red, green, blue (on the range 0-1). This is not something you would want, so you need to configure a layer, which returns NDVI index value rather than the color.
If you let me know, which account you are using and which instance you have (mask the second half of it), I can help you configure such layer.
Or try this:

1 Like