Skip to main content

I'm trying to calculate the percentage of nodata cells within a raster by using the point cloud combiner + point cloud splitter in fme to extract the value of cells with data vs cells with nodata, and get a ratio.

 

It's clearly not the right approach as it is taking forever. Is there a better way to do this?

 

Usually it would be fore raster tiles with 1,000,000 cells. Counting the nbr of nodata cells in each file basicallyfme_raster_validity 

 

Using the point cloud filter is what's needed. Filter, not splitter.

 

one filter with:

@Component(z)==@Value(_band{0}.band_nodata)

and another output with:

@Component(z)!=@Value(_band{0}.band_nodata)

fme_raster_validity2


Hi @ts_84​ , another approach, I think you can use RasterExtentsCoercer and AreaCalculator to get the areas of data extents and raster extents, and then calculate percentage of Nodata area from those areas.calculate-nodata-percentage


I have an RGB raster, 1600 x 1000 pixels, and am assuming 255 is nodata. What I tried is a RasterExpressionEvaluator using the expression:

 

Int8: if (AA0] < 255 && AA1] < 255 && AA2] < 255, 0, 1)

 

Basically, if a cell is <255 then create a value 0, else create a value 1.

 

Now I run this through a RasterStatisticsCalculator. It tells me that band0.sum = 235926

 

So (235926 / (1600 * 1000)) * 100 = 14.75, so 14.75% of my raster is made up of nodata.

 

The advantage of that method is that it's quick. The disadvantage is that it destroys the raster data. But it's easy enough to just get this result and then merge it back onto the original raster using a FeatureMerger.


I have an RGB raster, 1600 x 1000 pixels, and am assuming 255 is nodata. What I tried is a RasterExpressionEvaluator using the expression:

 

Int8: if (AA0] < 255 && AA1] < 255 && AA2] < 255, 0, 1)

 

Basically, if a cell is <255 then create a value 0, else create a value 1.

 

Now I run this through a RasterStatisticsCalculator. It tells me that band0.sum = 235926

 

So (235926 / (1600 * 1000)) * 100 = 14.75, so 14.75% of my raster is made up of nodata.

 

The advantage of that method is that it's quick. The disadvantage is that it destroys the raster data. But it's easy enough to just get this result and then merge it back onto the original raster using a FeatureMerger.

In case it helps, I made this one of our questions of the week and covered it here: https://www.youtube.com/watch?v=ZvSaHQ7gouI&t=87s


Reply