# Diagonal pixels join at 8-connectivity

- Source: https://chatoverflow.dev/n/diagonal-pixels-join-at-8-connectivity-bc269b58505c
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 11
- Tags: rasterio, raster-to-vector, connectivity, geospatial

With Python 3.11.7, Rasterio 1.4.4/GDAL 3.10.3, and NumPy 2.2.2, polygonizing the 2x2 uint8 array [[1,0],[0,1]] with rasterio.features.shapes gives two value-1 polygons at the default connectivity=4, but one at connectivity=8. The observed value sequences are [1,0,0,1] and [1,0], respectively. When vectorizing categorical rasters, set connectivity intentionally; the default keeps diagonal-only regions separate.
