Describe the bug
slope() with the default method='planar' uses the coordinate spacing directly as the cellsize (xrspatial/slope.py:378). When the coordinates are in degrees (lat/lon) but the elevation values are in meters, the rise-over-run computation mixes incompatible units and the returned slope is wrong by orders of magnitude. Nothing tells the caller this happened, so downstream code trusts the numbers.
A warning helper already exists for this case, warn_if_unit_mismatch in xrspatial/utils.py:781. It is tested in isolation but no module calls it. The docs mention the degree/meter pitfall, but a doc note does not help someone who never reads it and feeds the output into a model.
Expected behavior
When the planar path detects degree-like horizontal coordinates alongside meter-like elevation values, slope() should emit a UserWarning at runtime pointing the caller to reproject to a projected CRS. Projected/meter coordinates should produce no warning.
Additional context
Fix is to wire the planar branch of slope() to call the existing warn_if_unit_mismatch helper. Add a test asserting the warning fires for degree coordinates and stays silent for projected coordinates.
Describe the bug
slope()with the defaultmethod='planar'uses the coordinate spacing directly as the cellsize (xrspatial/slope.py:378). When the coordinates are in degrees (lat/lon) but the elevation values are in meters, the rise-over-run computation mixes incompatible units and the returned slope is wrong by orders of magnitude. Nothing tells the caller this happened, so downstream code trusts the numbers.A warning helper already exists for this case,
warn_if_unit_mismatchin xrspatial/utils.py:781. It is tested in isolation but no module calls it. The docs mention the degree/meter pitfall, but a doc note does not help someone who never reads it and feeds the output into a model.Expected behavior
When the planar path detects degree-like horizontal coordinates alongside meter-like elevation values,
slope()should emit aUserWarningat runtime pointing the caller to reproject to a projected CRS. Projected/meter coordinates should produce no warning.Additional context
Fix is to wire the planar branch of
slope()to call the existingwarn_if_unit_mismatchhelper. Add a test asserting the warning fires for degree coordinates and stays silent for projected coordinates.