I have this polygon:
ee.Geometry({
"functionInvocationValue": {
"functionName": "GeometryConstructors.Polygon",
"arguments": {
"coordinates": {
"constantValue": [
[
[
39.395406,
49.043902
],
[
39.395406,
49.046139
],
[
39.399011,
49.046139
],
[
39.399011,
49.043902
],
[
39.395406,
49.043902
]
]
]
},
"evenOdd": {
"constantValue": true
}
}
}
})
I would like to get the value in Sentinel-2 band 4 for all the pixels.
This is the code I'm using:
start_date,end_date = '2022-08-05','2022-08-07'
bands = ['B4']
sensor = "COPERNICUS/S2_SR_HARMONIZED"
img_collection = (ee.ImageCollection(sensor).filterBounds(polygon).filterDate(start_date,end_date).select(bands))
pixels_info = img_collection.getRegion(geometry=polygon, scale=10)
df = pd.DataFrame(pixels_info.getInfo())
df.columns = df.iloc[0]
df = df.drop(0)
df.shape
>>> (1000, 5)
This means there are 1000 pixels for a specific date (2022-08-06).
However, when I directly count the pixels, I get a different number:
img_id = 'COPERNICUS/S2_SR_HARMONIZED/20220806T082611_20220806T083525_T37UEQ'
image = ee.Image(img_id)
t_pixel_count = image.select(['B4']).reduceRegion(reducer=ee.Reducer.count(),geometry=polygon,scale=10).rename(['B4'],['total_pixels'])
t_pixel_count.getInfo()
>>> {'total_pixels': 666}
Why is that? and how many pixels there are in the image?