Q:

Extracting the Number of Pixels within Buffers around Various Points in Google Earth Engine?

I have a Feature Collection of various points, each of which I've drawn a 2.5km buffer around using the following:
    var bufferBy = function(size) {
      return function(feature) {
        return feature.buffer(size);   
      };
    };

After running a supervised SVM classification with only two possible output classes, either 0 or 1, I have determined the total number of pixels in both classes within the overlapping area of the buffers using the following:
    var sigP = classified_SVM_Park.reduceRegion({
      reducer: ee.Reducer.countEvery().group({
        groupName: 'signature',
      }),
      geometry: pBuffer.geometry(),
      scale: 30,
      maxPixels: 1e8
    });

How would I go about extracting the number of pixels assigned 0 and 1 within each buffer--in other words, the number of pixels within the buffer around each individual point?
Link to the full code is here: https://code.earthengine.google.com/54d0806b66fd31476a7a314f2da11df6

A:

You can actually do it quite simply with reduceRegions
Add this to your code.  It will create a featureCollection with the result of the reduction added to the properties of each feature.
var sigPColl = classified_SVM_Park.reduceRegions({
  collection: pBuffer,
  reducer: ee.Reducer.countEvery().group({
    groupName: 'signature',
  }),
  scale: 30
});
print(sigPColl,'Park Collection: Signature Count');

var sigRColl = classified_SVM_Ranch.reduceRegions({
  collection: rBuffer,
  reducer: ee.Reducer.countEvery().group({
    groupName: 'signature',
  }),
  scale: 30
});
print(sigRColl, 'Ranch Collection: Signature Count');

