Skip to main content

When we get the images for NDVI layer in WcsRequest, same way I tried for NDWI by adding layer in the specific configuration(specific instance Id) and adding NDWI Eval custom script but I am not able to fetch the NDWI values.

Please help me with this.


wcs_bands_request_ndvi = WcsRequest(data_folder=filepath,

layer=‘NDWI’,

bbox=betsiboka_bbox ,

time = date,

resx=‘10m’, resy=‘10m’,

image_format=MimeType.TIFF_d32f,

instance_id=INSTANCE_ID_VV,

time_difference = timedelta(days=1))

The above code works fine for NDVI for specific sentinelhub library but gives no value when tried for NDWI

Hi,


Thanks for the question, can you please provide some more information on what error you are returning and the evalscript that you are using please.


Thanks


Hi,

I solved that error.

Are there any limitations for downloading area through sentinel-hub?

Also have you come across this error - "cannot convert scaler to DataFrame’|

Thanks


Hi,


If referring to Process API, there is a limitation of 2500x2500 pixels. To download larger areas you can use either Batch Processing API (tiled result) or there is now Async Process API which is in public beta (upto 10,000x10,000 pixels).


As for the error can you give me some more details of how you came across it, so we can replicate the error.


Hi,

When I download the NDWI images and I layerstack them I get the error - > cannot convert scalar to DataFrame.


OK, what are you using to stack the images? Is this outside the APIs?


Yes…using the rioxarray library for this


After the images are downloaded using wcsrequest → I layerstack them but the error is coming only for NDWI


CODE-


def getLS(path1):

gfiles = glob(os.path.join(path1,’*.tiff’))

fdf = pd.DataFrame()


for file in gfiles:


date = file.split('\\')\-1].split('_')'7].split('T')'0].replace('-','_')
print(date)
try:
rds = rioxarray.open_rasterio(file,)
#print(rds)
rds = rds.squeeze().drop("spatial_ref")

#print('##################')
#print(rds)
rds.name = 'd'+date
df = rds.to_dataframe() -> getting error here -> cannot convert scalar to DF.
print(df)

#print(df)
#print(len(dfn'd'+date]adf]'d'+date].eq(0.0)]))
if len(dfn'd'+date]adf]'d'+date].eq(0.0)]) < 15:

df.drop("band",axis = 1,inplace = True)
if len(df.index.names) == 1:
if not (df.index.namesa0]=='y' or df.index.namesa0]=='x'):
df = df.set_index(d'y','x'])
elif df.index.namesa0]=='y':
df = df.set_index(d'x'], append=True)
elif df.index.namesa0]=='x':
df = df.reset_index()
df = df.set_index(d'y','x'])

fdf = pd.concat(cfdf,df],axis = 1)
except (Exception) as error :
print(error)
if error:
total_time = datetime.datetime.now()
logger_error.error(f' Error Occured While performing layerstack {path1}, time = {total_time} \n{error}')

#where path1 is path of downloaded NDWI images


This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.


Reply