Get percentage of not masked data of image clip


#1

Hello everyone!

I need to get the percentage of valid data on the resulting image clip of a polygon por each date. I was suggested to create a layer where I obtain 1 if any band has a value distinct of 0 and then use the FIS to get the statistics so the mean would be equivalent to percentage of valid data. When I do that on an image that I know does not cover the 100% of the polygon I still get 100%. I think that that is happening because the area with no date is masked and all calculations of the FIS are done over the unmasked area. So if that is true it would be much easier to get the masked area cover, How can I do that?

Attached is an image of the scene.

Thanks!


#2

Can you post an example of the FIS request you do? You can mask instance ID.


#3

The layer code:

let viz = new Identity();

function evaluatePixel(samples) {
let val = (samples[0].B02==0)?0:1;
return viz.process(val);
}

function setup(ds) {
setInputComponents([ds.B02]);
setOutputComponentCount(1);
}

the fis request

http://services.sentinel-hub.com/ogc/fis/m1h1dd3n1nst4nce?LAYER=COVERPERCENTAGE&CRS=EPSG:4326&TIME=2018-08-01/2018-08-17&RESOLUTION=10m&GEOMETRY=POLYGON((-32.28555%20-64.23295,-32.28555%20-64.22177,-32.29489%20-64.22177,-32.29489%20-64.23295,-32.28555%20-64.23295))

Fis output:

{“C0”:[{“date”:“2018-08-16”,“basicStats”:{“min”:1.0,“max”:1.0,“mean”:1.0,“stDev”:0.0}},{“date”:“2018-08-11”,“basicStats”:{“min”:1.0,“max”:1.0,“mean”:1.0,“stDev”:0.0}},{“date”:“2018-08-08”,“basicStats”:{“min”:1.0,“max”:1.0,“mean”:1.0,“stDev”:0.0}},{“date”:“2018-08-01”,“basicStats”:{“min”:1.0,“max”:1.0,“mean”:1.0,“stDev”:0.0}}]}

Regards!


Full area images VS part area images
#4

You are right, FIS already ignores pixels without value, so that retrieved statistics is still OK.
There is one trick you can do - if you add “&bins=1” at the end of your request, you will get something along the lines of:

C0
0
date “2018-08-16”
basicStats
min 1
max 1
mean 1
stDev 0
histogram
bins
0
value 1
count 5916.5625
1
date “2018-08-11”
basicStats
min 1
max 1
mean 1
stDev 0
histogram
bins
0
value 1
count 10920

“Count” tells you the number of pixels in each category, in this case there is only one category. You will notice that for 16/08 there are only 5.916 px (partly covered) and for 11/08 there are 10.920 (fully covered)

I hope this helps?

The other option is to use WFS and then take scene boundaries and do geometrical calculation yourself, but that might be complicated, especially on border of several scenes…


#5

Hello gmilcinski! Thanks for your quick reply, that information helps, but as the idea es to work without the need of looking at the images, it would be great to get the nodata cover value.

Thanks!!


Filter returned images from SentinelHub using JS-code in layer configuration