Magento 2.3 : How to set qty for multiple sources (Multi source inventory) programmatically

The maximum number of pieces has been studied under the name the lazy caterer's sequence, A000124. You have an arrangement of $n$ lines in general position, which has at most $n(n+1)/2+1$ cells, over which you lay your circle.

The figure below is from the Wikipedia article.


            LazyCat



Summing up attributes of images in an ImageCollection can be done using ee.ImageCollection.aggregate_sum().

A few other changes I made:

  • Switched to using a publicly accessible Feature Collection LSIB so that others can replicate.
  • Used the "50% confidence" test to mask out pixels of low confidence.
  • Updated the date range to include the entire year.

Here is the resulting script:

// Load Vietnam shapefile 
var lsib = ee.FeatureCollection("USDOS/LSIB_SIMPLE/2017");
var vn_shape = lsib.filterMetadata('country_na', 'equals', 'Vietnam');
print (vn_shape);

// Load fire counts image
var fire = ee.ImageCollection('FIRMS')
             .filterBounds(vn_shape)
             .filterDate('2010', '2011');

// Filter fire with more than 50% confidence and add a new band representing areas where confidence of fire > 50%
var filterConfidence = function(image) {
  var line_number = image.select('line_number');
  var confidence = image.select('confidence');
  var conf_50 = confidence.gt(50).rename('confidence_50');
  var count_band = line_number.updateMask(conf_50).rename('count');
  return image.addBands(count_band);
};
var fire_conf = fire.map(filterConfidence);
print('fire_conf', fire_conf);

// Count for individual image.
var countIndividualImg = function(image) {
  var countObject = image.reduceRegion({
    reducer: ee.Reducer.countDistinct(),
    scale: 1000,
    geometry: vn_shape
  });
  return image.set(countObject);
};
var fire_ind_count = fire_conf.map(countIndividualImg);
print('fire_ind_count', fire_ind_count);

print('Total fire count', fire_ind_count.aggregate_sum('count'));