I use rasterio.features.shapes
and use the geometry of pixels in raster data to create polygons for each pixel. Pixels with the same value merge these pixels if they are adjacent.
What I want is for each pixel to be in the form of separate polygons. How can I do it?
import rasterio
from rasterio.features import shapes
mask = None
with rasterio.Env():
with rasterio.open(r"C:\Users\Lenovo\Desktop\clipped.tiff") as src:
image = src.read(1) # first band
results = (
{'properties': {'raster_val': v}, 'geometry': s}
for i, (s, v)
in enumerate(
shapes(image, transform=src.transform)))
geoms = list(results)
The result (the red area is the combination of two same value pixels):