Our dem.tif uses EPSG:4326, a geographic CRS, exactly the case flagged as risky back in Session 03. transform.a and transform.e here are tiny numbers, around 0.001, because they are measured in degrees, not meters, while every elevation value in the array is in meters. Feeding a meter-scale elevation difference straight into a degree-scale spacing produces a gradient many orders of magnitude too large, and arctan of a huge number saturates at 90 degrees. This is exactly why a first attempt at this calculation often produces a slope map that shows nearly every pixel at 90 degrees, a uniform, clearly wrong result, and a completely empty gentle-slope mask afterward. Always check src.crs.is_geographic before treating transform.a/transform.e as real ground distances.