=== versions === python 3.12.0 | scikit-learn 1.9.1 | scipy 1.18.1 | rasterio 1.5.2 | contextily 1.7.1 | geopandas 1.2.0 === data (same cleaning as Part 1) === snapshot uploaded 26 October 2026: 27,552 council trees in the borough, 3,292 London planes grid: 305 x 267 cells of 25 m, 34,847 inside the borough === bandwidth selection === scipy gaussian_kde: Scott factor 0.2593, Silverman factor 0.2593 kernel standard deviation (from the data covariance): 470 m east-west, 417 m north-south scikit-learn KernelDensity(bandwidth='scott').bandwidth_ = 0.259 -> read as metres on raw coordinates: standardise first or pass a number likelihood cross-validation (5-fold, 25 bandwidths from 10 to 1,000 m): best h = 32 m h = 10 m: mean held-out log-likelihood -18.333 per tree h = 22 m: mean held-out log-likelihood -15.687 per tree h = 46 m: mean held-out log-likelihood -15.709 per tree h = 100 m: mean held-out log-likelihood -16.136 per tree h = 215 m: mean held-out log-likelihood -16.564 per tree h = 464 m: mean held-out log-likelihood -16.919 per tree h = 1000 m: mean held-out log-likelihood -17.335 per tree fixed planning distance: Epanechnikov kernel, radius 400 m (same spread as a Gaussian with sd 163 m) Scott/Silverman (Gaussian, sd 470 × 417 m): peak 3.3 planes/ha, 99th percentile 3.1, share of the kernel mass inside the borough 0.818 likelihood CV (Gaussian, sd 32 m): peak 37.4 planes/ha, 99th percentile 15.0, share of the kernel mass inside the borough 0.980 planning distance (Epanechnikov, radius 400 m): peak 5.3 planes/ha, 99th percentile 4.4, share of the kernel mass inside the borough 0.913 === kernel comparison at the same spread (sd 100 m per axis) === gaussian: h = 100 m, peak 9.7 planes/ha, correlation with Gaussian r = 1.000 epanechnikov: h = 245 m, peak 8.7 planes/ha, correlation with Gaussian r = 0.990 tophat: h = 200 m, peak 8.4 planes/ha, correlation with Gaussian r = 0.967 exponential: h = 58 m, peak 13.5 planes/ha, correlation with Gaussian r = 0.977 === sample weights: crown area === 3,288 of 3,292 planes have a crown spread > 0 (median 11 m); total crown area 38.6 ha Gaussian h = 100 m: peak 9.7 planes/ha; peak crown density 19.7% of the ground under plane crowns correlation between count and crown-area surfaces: r = 0.859 count peak at E 528438 N 185888; crown-area peak at E 529738 N 183462 (2,751 m apart) === GeoTIFF export === edge correction factor 1/c(x): median 1.00, max 3.69 (cells on the boundary) wrote output\camden_london_plane_density.tif: 305 x 267 cells, EPSG:27700, 25 m, float32, nodata -9999, 131 KB read back: max 11.0 trees/ha, mean 1.51 trees/ha (the borough average is 1.51) === relative risk: London planes vs all other council trees === cases 3,292 planes, controls 24,260 other trees; common Gaussian h = 150 m correlation of the raw plane density with the density of all council trees: r = 0.45 72% of the borough has >= 5 other trees per ha (elsewhere the ratio is masked) log2 relative risk, 1st to 99th percentile: -3.65 to 2.30 (planes 0.08x to 4.9x their borough-wide share) pointwise p <= 0.05 (planes over-represented), 199 random labellings: 28.9% of valid cells (4.50 km2); about 5% would be flagged by chance alone === plane share by land owner === London plane share of council trees by contract area: Highways 17%, Parks 13%, Housing 7%, Education 5%, Corporate Landlord 2%, Valuers 0% borough-wide share: 11.9%