Skip to content

Commit e71f4c4

Browse files
committed
Fix review findings: proximity units, terrain dtype, missing pages (#1133)
- Proximity EUCLIDEAN returns coordinate-unit distances, not pixels - Great-circle returns metres, not kilometres - Terrain metrics output float64, not float32; drop Horn attribution - Add admonitions to multispectral, zonal, and pathfinding pages - Clarify haversine section title
1 parent 646f45e commit e71f4c4

File tree

6 files changed

+46
-23
lines changed

6 files changed

+46
-23
lines changed

docs/source/reference/multispectral.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
Multispectral
55
*************
66

7+
.. note::
8+
9+
All spectral indices output **float32**. Division by zero (e.g.
10+
NDVI where NIR + Red = 0) produces NaN or inf silently. Clean
11+
the result with ``xr.where(np.isfinite(result), result, np.nan)``
12+
if needed.
13+
714
Atmospherically Resistant Vegetation Index (ARVI)
815
=================================================
916
.. autosummary::

docs/source/reference/pathfinding.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@
44
Pathfinding
55
***********
66

7+
.. caution::
8+
9+
A* allocates about 65 bytes per pixel and will raise ``MemoryError``
10+
if the required memory exceeds 80 % of available RAM. Use Dask or
11+
set ``search_radius`` to limit the search area for large rasters.
12+
13+
.. warning::
14+
15+
NaN and non-positive friction values are treated as impassable
16+
barriers. Cells must have finite positive friction to be traversable.
17+
718
A* Pathfinding
819
==============
920
.. autosummary::

docs/source/reference/proximity.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ Proximity
66

77
.. warning::
88

9-
``proximity()`` returns distances in **pixel units** by default
10-
(``distance_metric='EUCLIDEAN'``). Multiply by cell size to get
11-
real-world units, or use ``'GREAT_CIRCLE'`` for lat/lon data
12-
(returns kilometres).
9+
``proximity()`` with ``distance_metric='EUCLIDEAN'`` (the default)
10+
returns distances in the **coordinate units** of the DataArray.
11+
With default integer indices this equals pixel counts. Use
12+
``'GREAT_CIRCLE'`` for lat/lon data (returns metres).
1313

1414
.. caution::
1515

docs/source/reference/terrain_metrics.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ Terrain Metrics
66

77
.. note::
88

9-
Terrain metrics use a 3x3 kernel and output **float32**. Edge cells
10-
are NaN by default. These functions use the planar (Horn) algorithm
11-
and assume the input is on a regular grid with uniform cell spacing.
9+
Terrain metrics use a 3x3 neighbourhood and output **float64**. Edge
10+
cells are NaN. These functions assume the input is on a regular grid
11+
with uniform cell spacing.
1212

1313
Roughness
1414
=========

docs/source/reference/zonal.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
Zonal
55
*****
66

7+
.. note::
8+
9+
NaN values are excluded from all zonal aggregations. A zone where
10+
every cell is NaN returns NaN (not zero) for sum, mean, etc.
11+
712
Apply
813
=====
914
.. autosummary::

docs/source/user_guide/caveats.rst

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -118,41 +118,41 @@ the output cell is NaN. The exact behaviour varies by function:
118118
``boundary='reflect'`` if you need values at the edges.
119119

120120

121-
Proximity defaults to pixel units
122-
==================================
121+
Proximity distances depend on coordinate units
122+
================================================
123123

124124
.. warning::
125125

126-
``proximity()`` returns distances in **pixel units** when
127-
``distance_metric='EUCLIDEAN'`` (the default). It does not automatically
128-
convert to metres or kilometres.
126+
``proximity()`` with ``distance_metric='EUCLIDEAN'`` (the default)
127+
computes distances in whatever units the DataArray's coordinates use.
128+
If coordinates are default integer indices (0, 1, 2, ...), the result
129+
is in pixel counts. If coordinates are in metres (UTM), the result is
130+
in metres. If coordinates are in degrees, the result is in degrees.
129131

130-
To get distances in real-world units with Euclidean mode, multiply the
131-
result by your cell size. Or switch to ``distance_metric='GREAT_CIRCLE'``
132-
if your data is in degrees, which returns kilometres.
132+
Switch to ``distance_metric='GREAT_CIRCLE'`` for lat/lon data to get
133+
distances in **metres** (the radius used is 6 378 137 m).
133134

134135
.. tip::
135136

136137
.. code-block:: python
137138
138139
from xrspatial.proximity import proximity
139140
140-
# Pixel-unit result
141+
# EUCLIDEAN with default coords = pixel-count distances
141142
dist_px = proximity(raster)
142143
143-
# Convert to metres (assumes square cells)
144-
cell_m = 30.0 # e.g. Landsat 30 m resolution
145-
dist_m = dist_px * cell_m
144+
# GREAT_CIRCLE with lat/lon coords = distances in metres
145+
dist_m = proximity(raster, distance_metric='GREAT_CIRCLE')
146146
147147
148-
Haversine uses the semi-major axis
149-
====================================
148+
Great-circle distances assume sphere radius = semi-major axis
149+
==============================================================
150150

151151
.. note::
152152

153153
Great-circle distances in ``proximity()`` and ``surface_distance()``
154-
use the WGS84 **semi-major axis** (6 378 137 m) as the Earth radius,
155-
not the mean radius (6 371 km).
154+
model the Earth as a sphere with radius = WGS84 semi-major axis
155+
(6 378 137 m), not the mean radius (~6 371 km).
156156

157157
The difference is about 0.1 %. This is negligible for most use cases but
158158
worth knowing if you're comparing against a reference that uses the mean

0 commit comments

Comments
 (0)