I'm completely new to python usage in GIS. I'm working with Sentinel images and want to sample the pixels of raster file only in the places which are represented by the geometry of the truth data which I have it in the form of shapefile. All I want to find is the analogous of the below code in Python.
var training = image.select(bands).sampleRegions({
collection: points,
properties: [class],
scale: 30
});
image.select(bands) - is my raster data,
Collection- is my shapefile
Trying to find my output as the below image. Source : https://miro.medium.com/max/1050/1*WrtLqr49lbpf24K3Pb6ViQ.png [![enter image description here][1]][1]
I wanted to do some sampling like in the above link, it has clustering and sampling of trees based on their heights but I want to sample and cluster pixels only in the locations based on the geometries of my shapefile i.e, wanted to acheive supervised classification.