=== versions === python 3.12.0 | rasterio 1.5.2 (GDAL 3.12.2) | rio-cogeo 7.0.4 | geopandas 1.2.0 | shapely 2.2.0 === Step 1: Greater Manchester districts (ONS LAD December 2024, BFC) === 10 districts, CRS EPSG:27700, total area 1,276.0 km2 bounds (lon/lat): [-2.7304 53.3272 -1.9096 53.6857] === Step 2: read ESA WorldCover 2021 for Greater Manchester (Planetary Computer) === STAC item: ESA_WorldCover_10m_2021_v200_N51W003 remote COG: 36000 x 36000 px, 1024 x 1024 tiles, deflate, 103.0 MB on the server window read: 9850 x 4302 px using 6 HTTP range requests, 2.96 MB downloaded (2.9% of the file) saved worldcover_gm_plain.tif: 40.4 MB, CRS EPSG:4326, pixel 8.333e-05 x 8.333e-05 degrees pixel size on the ground: 51.1 to 51.5 m2 (north to south edge of the subset), not 100 m2 === Step 3: rasterize the districts onto the WorldCover grid === pixels inside Greater Manchester: 24,905,429 (centre rule) vs 24,927,992 (all_touched) rasterized area 1,276.9 km2 vs vector area 1,276.0 km2 (+0.07%) Greater Manchester land cover (% of area): Tree cover 32.2 Shrubland 0.0 Grassland 33.9 Cropland 3.6 Built-up 29.4 Bare / sparse 0.1 Water 0.9 Herbaceous wetland 0.0 by district (% of district area): Built-up Tree cover Grassland Cropland Water LAD24NM Manchester 50.5 37.8 11.1 0.1 0.4 Salford 34.7 35.8 19.6 8.1 1.3 Trafford 32.6 35.8 20.4 10.1 1.0 Stockport 30.8 39.3 28.8 0.9 0.1 Tameside 29.9 31.7 36.9 0.2 1.1 Bolton 28.3 33.2 34.6 3.2 0.5 Wigan 26.8 34.1 28.0 10.0 1.1 Bury 24.9 35.5 37.8 0.8 0.7 Oldham 22.3 20.8 55.5 0.5 0.8 Rochdale 20.1 23.0 54.8 0.5 1.5 === Step 4: vectorise water with rasterio.features.shapes === connectivity=4: 1,302 polygons in 0.68 s connectivity=8: 1,186 polygons in 0.65 s total water area: polygons 11.047 km2, pixel count x pixel area 11.055 km2 single-pixel polygons: 366 of 1,302 (28%), holding 0.2% of the water area polygon area: median 409 m2, 90th percentile 11562 m2, 99th 172,443 m2, max 64.5 ha round trip (shapes -> to_crs -> back -> rasterize): 0 pixels differ out of 42,374,700 after sieve(size=10): 611 polygons, water area 10.966 km2 (-0.8%) 48 water bodies >= 5 ha; the largest: 64.5 ha Wigan centroid 53.4866 N, -2.5483 E 51.0 ha Tameside centroid 53.4642 N, -2.1331 E 40.9 ha Rochdale centroid 53.6303 N, -2.0969 E 35.6 ha Rochdale centroid 53.6575 N, -2.1388 E 34.3 ha Oldham centroid 53.5307 N, -1.9758 E 27.4 ha Wigan centroid 53.5284 N, -2.6360 E 26.7 ha Rochdale centroid 53.6606 N, -2.0443 E 26.5 ha Tameside centroid 53.4676 N, -2.1279 E === Step 5: vectorise built-up land and simplify === connectivity=8: 8,802 polygons in 2.6 s, 1,121 invalid (e.g. Ring Self-intersection) shapely.make_valid() repairs them; geometry types now: [6] (6 = MultiPolygon) connectivity=4: 9,343 polygons in 3.2 s, 0 invalid 9,343 built-up polygons kept (sieve size=10, connectivity=4); largest 193.7 km2 (51% of all built-up area); 13,882 holes in total tolerance_m vertices area_km2 invalid gpkg_MB area_change_% vertices_% 0.0 1144229 376.400 0 19.578 0.000 100.000 2.5 1144229 376.400 0 19.578 0.000 100.000 5.0 687426 376.539 0 12.211 0.037 60.078 10.0 320242 376.996 0 6.375 0.158 27.988 20.0 197609 376.749 0 4.398 0.093 17.270 40.0 140651 377.037 0 3.539 0.169 12.292 === Step 5b: simplify a polygon coverage without gaps (shapely.coverage_simplify) === 1,883 polygons covering 16.123 km2, 48,822 vertices simplify(10) vertices 19,303 overlaps 92,228 m2 gaps 127,716 m2 coverage_simplify(10) vertices 27,988 overlaps 0 m2 gaps 0 m2 === Step 6: convert the GeoTIFF to a Cloud Optimized GeoTIFF === plain GeoTIFF valid COG? False errors: ['The file is greater than 512xH or 512xW, but is not tiled'] warnings: ['The file is greater than 512xH or 512xW, it is recommended to include internal overviews'] rio-cogeo COG written in 7.1 s; valid COG? True; errors: []; warnings: [] GDAL COG driver (rasterio.shutil.copy) in 5.1 s: valid COG? True; errors: [] file sizes (MB): Plain GeoTIFF (uncompressed) 40.44 GeoTIFF, DEFLATE, strips 1.99 COG, LZW 2.51 COG, DEFLATE (rio-cogeo) 2.60 COG, DEFLATE (GDAL driver) 2.60 COG, ZSTD 2.58 COG pixels identical to the source: True; overview factors [2, 4, 8, 16]; blocks (512, 512); source blocks (1, 9850) === Step 7: read a window and a thumbnail over HTTP (range requests) === file job requests MB pct_of_file pixels seconds Plain GeoTIFF 4 km x 4 km window, full resolution 3 4.125 10.201 726 x 433 0.143 Plain GeoTIFF whole-area thumbnail, 1/16 resolution 204 15.094 37.327 615 x 268 0.864 COG (DEFLATE) 4 km x 4 km window, full resolution 3 0.127 4.895 726 x 433 0.009 COG (DEFLATE) whole-area thumbnail, 1/16 resolution 2 0.047 1.805 615 x 268 0.007 === figures === saved 5 figures to output/