Generating EVI (Enhanced Vegetation Index) from Sentinel-2

Hi,

I am going to generate EVI from Sentinel-2, but I am getting the below error:

java.lang.AssertionError: assertion failed: Band 4 cell type does not match, float64 != float32’}]

To export them, I am using the following code, which is working for other indexes (e.g., “NDVI”,“NDMI”,“GNDVI”,“NMDI”), but I am getting the error only for EVI or EVI2.

idx_list = [“NDVI”,“NDMI”,“GNDVI”,“NMDI”,“EVI”]
S2_VIs_2021 = opc.compute_indices(cube_masked_2021, idx_list).filter_bands(idx_list)

S2_2021_daily = S2_VIs_2021.aggregate_temporal_period(“day”,reducer=“median”)

cropland_mask = connection.load_collection(“ESA_WORLDCOVER_10M_2021_V2”, bands=[“MAP”],
temporal_extent = [“2021-01-01”, “2022-01-01”],
spatial_extent={“west”: 34.282, “south”: 0.658, “east”: 34.447, “north”: 0.769}
)

cropland_mask = cropland_mask.band(“MAP”) != 40
S2_2021_input_crop = S2_2021_daily.mask(cropland_mask.max_time())

job = S2_2021_input_crop.create_job(out_format=“GTiff”)
job.start_and_wait()
job.get_results()

Hi,

Can you share a job_id?
If you call an UDF, it might be that you have to call (...).astype(np.dtype('float64') before returning the result.

Greetings,
Emile Sonneveld

Hi Emile,

Here is the id:
vito-j-240502fd00794c29be06e60c6a5fe11b

I have also tried EVI2, but still not working.
I am not using an UDF for this case.

Best,
Mohammad

Hi,

I found an issue and prepared a fix which will take some time to go online. It is tracked in this issue:

I do not have a very easy workaround. I do think it is related to the use of array_create, so it might be that for instance appending the EVI would fix it, but it may be a hassle to change this, hence it’s easier to continue without evi until the fix is out, or to compute evi separately.

While working on your job, I also noticed:

  • using SENTINEL2_L2A might be a better choice, it is faster if data is available on terrascope
  • best to drop the use of resample_cube_spatial I don’t think it’s needed in your case
  • when you mask using SCL, I recommend to create a separate datacube for SCL, allowing to improve performance by only loading data of bands that are not masked.

Hi Jeroen,

Thanks for following up.
I will try to compute evi without using the default indexes’ list.

Okay. I follow your notices on the code.

Hi Mohammad,
the bugfix is now also available online, so you can try again.

best regards,
Jeroen

Hi Jeroen,

Thanks. It’s working.

Mohammad