EDIT
I I was able to modify the pixel Points coordinates by using the rasterio.transform method, the SHP file works on QGIS, and the coordinates are almost aligned, but not exactly.
I tried many combination but never the shape exactly cover the TIFF extent...
import rasterio
from rasterio.plot import show
from rasterio.windows import Window
import shapefile
flat_list = [item for sublist in B for item in sublist]
w = shapefile.Writer('03-c')
w.field('name', 'C')
image = '/content/drive/My Drive/ML/03.tif'
with rasterio.open(image) as src:
for i in range(len(flat_list)):
### X & Y is the center of the rectangle in flatlist[]
X = (int((flat_list[i][0])/2+flat_list[i][2]))
Y = (src.shape[0] - int((flat_list[i][1]+flat_list[i][3])/2))
Point = src.transform * (X, Y)
w.point(Point[0], Point[1])
w.record('linestring1')
w.close()
import rasterio
from rasterio.plot import show
from rasterio.windows import Window
import shapefile
flat_list = [item for sublist in B for item in sublist]
w = shapefile.Writer('03-c')
w.field('name', 'C')
image = '/content/drive/My Drive/ML/03.tif'
with rasterio.open(image) as src:
for i in range(len(flat_list)):
### X & Y is the center of the rectangle in flatlist[]
X = (int((flat_list[i][0])/2+flat_list[i][2]))
Y = (src.shape[0] - int((flat_list[i][1]+flat_list[i][3])/2))
Point = src.transform * (X, Y)
w.point(Point[0], Point[1])
w.record('linestring1')
w.close()