Description
aspect() with the default method='planar' silently produces wrong results when given a lat/lon raster (coordinates in degrees) with elevation values in meters. The planar path in xrspatial/aspect.py calls get_dataarray_resolution(agg) directly, without first checking whether the horizontal units (degrees) match the vertical units (meters).
slope() already guards against this. Its planar path calls warn_if_unit_mismatch(agg) before computing resolution, so the user gets a UserWarning when degrees and meters are mixed. Aspect divides elevation differences by cell size the same way slope does, so it has the same problem, just without the warning.
Expected behavior
Aspect's planar path should call the same warn_if_unit_mismatch() helper that slope uses, before computing resolution, so users get warned when horizontal units don't match vertical units.
Steps to reproduce
Call aspect() on a DataArray with degree-based lat/lon coordinates and meter elevation values. slope() warns; aspect() does not.
Scope
One-line behavior fix plus a test. It reuses slope's existing helper and import. The other aspect findings (dask memory guard, name leak, z_unit error message) are tracked separately.
Description
aspect()with the defaultmethod='planar'silently produces wrong results when given a lat/lon raster (coordinates in degrees) with elevation values in meters. The planar path inxrspatial/aspect.pycallsget_dataarray_resolution(agg)directly, without first checking whether the horizontal units (degrees) match the vertical units (meters).slope()already guards against this. Its planar path callswarn_if_unit_mismatch(agg)before computing resolution, so the user gets aUserWarningwhen degrees and meters are mixed. Aspect divides elevation differences by cell size the same way slope does, so it has the same problem, just without the warning.Expected behavior
Aspect's planar path should call the same
warn_if_unit_mismatch()helper that slope uses, before computing resolution, so users get warned when horizontal units don't match vertical units.Steps to reproduce
Call
aspect()on a DataArray with degree-based lat/lon coordinates and meter elevation values.slope()warns;aspect()does not.Scope
One-line behavior fix plus a test. It reuses slope's existing helper and import. The other aspect findings (dask memory guard, name leak, z_unit error message) are tracked separately.