Skip to content

Commit 2af1e1f

Browse files
committed
Fix pre-existing docs build errors (#1021)
- hydrology.rst: point autosummary entries to actual module paths (xrspatial.hydro.*.* instead of non-existent xrspatial.*.*) - multispectral.rst: fix Built=Up typo to Built-Up - multispectral.py: fix ndvi plot directive indentation - emerging_hotspots.py: fix RST table indentation and add blank line - zonal.py: fix crop example using zones_ids=[0] on terrain with no zeros; create a proper binary zone raster instead
1 parent 324cace commit 2af1e1f

5 files changed

Lines changed: 120 additions & 70 deletions

File tree

docs/source/reference/hydrology.rst

Lines changed: 82 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,164 +4,206 @@
44
Hydrology
55
*********
66

7-
Flow Direction
8-
==============
7+
Flow Direction (D8)
8+
===================
99
.. autosummary::
1010
:toctree: _autosummary
1111

12-
xrspatial.flow_direction.flow_direction
12+
xrspatial.hydro.flow_direction_d8.flow_direction_d8
1313

1414
Flow Direction (D-infinity)
1515
===========================
1616
.. autosummary::
1717
:toctree: _autosummary
1818

19-
xrspatial.flow_direction_dinf.flow_direction_dinf
19+
xrspatial.hydro.flow_direction_dinf.flow_direction_dinf
2020

2121
Flow Direction (MFD)
2222
====================
2323
.. autosummary::
2424
:toctree: _autosummary
2525

26-
xrspatial.flow_direction_mfd.flow_direction_mfd
26+
xrspatial.hydro.flow_direction_mfd.flow_direction_mfd
2727

28-
Flow Accumulation
29-
=================
28+
Flow Accumulation (D8)
29+
======================
3030
.. autosummary::
3131
:toctree: _autosummary
3232

33-
xrspatial.flow_accumulation.flow_accumulation
33+
xrspatial.hydro.flow_accumulation_d8.flow_accumulation_d8
3434

3535
Flow Accumulation (D-infinity)
3636
===============================
3737
.. autosummary::
3838
:toctree: _autosummary
3939

40-
xrspatial.flow_accumulation_dinf.flow_accumulation_dinf
40+
xrspatial.hydro.flow_accumulation_dinf.flow_accumulation_dinf
4141

4242
Flow Accumulation (MFD)
4343
=======================
4444
.. autosummary::
4545
:toctree: _autosummary
4646

47-
xrspatial.flow_accumulation_mfd.flow_accumulation_mfd
47+
xrspatial.hydro.flow_accumulation_mfd.flow_accumulation_mfd
4848

49-
Flow Length
50-
===========
49+
Flow Length (D8)
50+
================
5151
.. autosummary::
5252
:toctree: _autosummary
5353

54-
xrspatial.flow_length.flow_length
54+
xrspatial.hydro.flow_length_d8.flow_length_d8
5555

5656
Flow Length (D-infinity)
5757
========================
5858
.. autosummary::
5959
:toctree: _autosummary
6060

61-
xrspatial.flow_length_dinf.flow_length_dinf
61+
xrspatial.hydro.flow_length_dinf.flow_length_dinf
6262

6363
Flow Length (MFD)
6464
=================
6565
.. autosummary::
6666
:toctree: _autosummary
6767

68-
xrspatial.flow_length_mfd.flow_length_mfd
68+
xrspatial.hydro.flow_length_mfd.flow_length_mfd
69+
70+
Flow Path (D8)
71+
==============
72+
.. autosummary::
73+
:toctree: _autosummary
74+
75+
xrspatial.hydro.flow_path_d8.flow_path_d8
76+
77+
Flow Path (D-infinity)
78+
======================
79+
.. autosummary::
80+
:toctree: _autosummary
81+
82+
xrspatial.hydro.flow_path_dinf.flow_path_dinf
6983

70-
Flow Path
71-
=========
84+
Flow Path (MFD)
85+
===============
7286
.. autosummary::
7387
:toctree: _autosummary
7488

75-
xrspatial.flow_path.flow_path
89+
xrspatial.hydro.flow_path_mfd.flow_path_mfd
7690

7791
Fill
7892
====
7993
.. autosummary::
8094
:toctree: _autosummary
8195

82-
xrspatial.fill.fill
96+
xrspatial.hydro.fill_d8.fill_d8
8397

8498
Sink
8599
====
86100
.. autosummary::
87101
:toctree: _autosummary
88102

89-
xrspatial.sink.sink
103+
xrspatial.hydro.sink_d8.sink_d8
90104

91105
Basin
92106
=====
93107
.. autosummary::
94108
:toctree: _autosummary
95109

96-
xrspatial.basin.basin
110+
xrspatial.hydro.basin_d8.basin_d8
97111

98-
Watershed
99-
=========
112+
Watershed (D8)
113+
==============
100114
.. autosummary::
101115
:toctree: _autosummary
102116

103-
xrspatial.watershed.watershed
104-
xrspatial.watershed.basins
117+
xrspatial.hydro.watershed_d8.watershed_d8
118+
xrspatial.hydro.watershed_d8.basins_d8
119+
120+
Watershed (D-infinity)
121+
======================
122+
.. autosummary::
123+
:toctree: _autosummary
124+
125+
xrspatial.hydro.watershed_dinf.watershed_dinf
126+
127+
Watershed (MFD)
128+
===============
129+
.. autosummary::
130+
:toctree: _autosummary
131+
132+
xrspatial.hydro.watershed_mfd.watershed_mfd
105133

106134
Snap Pour Point
107135
===============
108136
.. autosummary::
109137
:toctree: _autosummary
110138

111-
xrspatial.snap_pour_point.snap_pour_point
139+
xrspatial.hydro.snap_pour_point_d8.snap_pour_point_d8
112140

113-
Stream Link
114-
===========
141+
Stream Link (D8)
142+
================
115143
.. autosummary::
116144
:toctree: _autosummary
117145

118-
xrspatial.stream_link.stream_link
146+
xrspatial.hydro.stream_link_d8.stream_link_d8
119147

120148
Stream Link (D-infinity)
121149
========================
122150
.. autosummary::
123151
:toctree: _autosummary
124152

125-
xrspatial.stream_link_dinf.stream_link_dinf
153+
xrspatial.hydro.stream_link_dinf.stream_link_dinf
126154

127155
Stream Link (MFD)
128156
=================
129157
.. autosummary::
130158
:toctree: _autosummary
131159

132-
xrspatial.stream_link_mfd.stream_link_mfd
160+
xrspatial.hydro.stream_link_mfd.stream_link_mfd
133161

134-
Stream Order
135-
============
162+
Stream Order (D8)
163+
=================
136164
.. autosummary::
137165
:toctree: _autosummary
138166

139-
xrspatial.stream_order.stream_order
167+
xrspatial.hydro.stream_order_d8.stream_order_d8
140168

141169
Stream Order (D-infinity)
142170
=========================
143171
.. autosummary::
144172
:toctree: _autosummary
145173

146-
xrspatial.stream_order_dinf.stream_order_dinf
174+
xrspatial.hydro.stream_order_dinf.stream_order_dinf
147175

148176
Stream Order (MFD)
149177
==================
150178
.. autosummary::
151179
:toctree: _autosummary
152180

153-
xrspatial.stream_order_mfd.stream_order_mfd
181+
xrspatial.hydro.stream_order_mfd.stream_order_mfd
182+
183+
Height Above Nearest Drainage (D8)
184+
===================================
185+
.. autosummary::
186+
:toctree: _autosummary
187+
188+
xrspatial.hydro.hand_d8.hand_d8
189+
190+
Height Above Nearest Drainage (D-infinity)
191+
==========================================
192+
.. autosummary::
193+
:toctree: _autosummary
194+
195+
xrspatial.hydro.hand_dinf.hand_dinf
154196

155-
Height Above Nearest Drainage (HAND)
156-
=====================================
197+
Height Above Nearest Drainage (MFD)
198+
====================================
157199
.. autosummary::
158200
:toctree: _autosummary
159201

160-
xrspatial.hand.hand
202+
xrspatial.hydro.hand_mfd.hand_mfd
161203

162204
Topographic Wetness Index (TWI)
163205
===============================
164206
.. autosummary::
165207
:toctree: _autosummary
166208

167-
xrspatial.twi.twi
209+
xrspatial.hydro.twi_d8.twi_d8

docs/source/reference/multispectral.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ Atmospherically Resistant Vegetation Index (ARVI)
1111

1212
xrspatial.multispectral.arvi
1313

14-
Enhanced Built=Up and Bareness Index (EBBI)
15-
===========================================
14+
Enhanced Built-Up and Bareness Index (EBBI)
15+
============================================
1616
.. autosummary::
1717
:toctree: _autosummary
1818

xrspatial/emerging_hotspots.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -661,21 +661,22 @@ def emerging_hotspots(raster, kernel, boundary='nan'):
661661
662662
Category codes
663663
--------------
664-
==== ============ ==================================
665-
Code Name Rule
666-
==== ============ ==================================
667-
1 New Hot only at the final time step
668-
2 Consecutive Hot for final N consecutive steps
669-
(N>=2), never before
670-
3 Intensifying Hot >=90% incl. final, MK up
671-
4 Persistent Hot >=90% incl. final, MK flat
672-
5 Diminishing Hot >=90% incl. final, MK down
673-
6 Sporadic Hot at final, <90%, never cold
674-
7 Oscillating Hot at final, was cold at least once
675-
8 Historical Hot >=90% of steps, NOT at final
676-
-1..-8 Cold spot mirrors of 1-8
677-
0 No Pattern None of the above
678-
==== ============ ==================================
664+
665+
====== ============ ======================================
666+
Code Name Rule
667+
====== ============ ======================================
668+
1 New Hot only at the final time step
669+
2 Consecutive Hot for final N consecutive steps
670+
(N>=2), never before
671+
3 Intensifying Hot >=90% incl. final, MK up
672+
4 Persistent Hot >=90% incl. final, MK flat
673+
5 Diminishing Hot >=90% incl. final, MK down
674+
6 Sporadic Hot at final, <90%, never cold
675+
7 Oscillating Hot at final, was cold at least once
676+
8 Historical Hot >=90% of steps, NOT at final
677+
-1..-8 Cold spot mirrors of 1-8
678+
0 No Pattern None of the above
679+
====== ============ ======================================
679680
"""
680681
if not isinstance(raster, xr.DataArray):
681682
raise TypeError("`raster` must be an xarray.DataArray")

xrspatial/multispectral.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -704,16 +704,17 @@ def ndvi(nir_agg: xr.DataArray,
704704
--------
705705
.. plot::
706706
:include-source:
707-
>>> from xrspatial.datasets import get_data
708-
>>> data = get_data('sentinel-2') # Open Example Data
709-
>>> nir = data['NIR']
710-
>>> red = data['Red']
711-
>>> from xrspatial.multispectral import ndvi
712-
>>> # Generate NDVI Aggregate Array
713-
>>> ndvi_agg = ndvi(nir_agg=nir, red_agg=red)
714-
>>> nir.plot(aspect=2, size=4)
715-
>>> red.plot(aspect=2, size=4)
716-
>>> ndvi_agg.plot(aspect=2, size=4)
707+
708+
>>> from xrspatial.datasets import get_data
709+
>>> data = get_data('sentinel-2') # Open Example Data
710+
>>> nir = data['NIR']
711+
>>> red = data['Red']
712+
>>> from xrspatial.multispectral import ndvi
713+
>>> # Generate NDVI Aggregate Array
714+
>>> ndvi_agg = ndvi(nir_agg=nir, red_agg=red)
715+
>>> nir.plot(aspect=2, size=4)
716+
>>> red.plot(aspect=2, size=4)
717+
>>> ndvi_agg.plot(aspect=2, size=4)
717718
718719
.. sourcecode:: python
719720

xrspatial/zonal.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2336,12 +2336,18 @@ def crop(
23362336
terrain_agg = terrain_agg.rename({'x': 'lon', 'y': 'lat'})
23372337
terrain_agg = terrain_agg.rename('Elevation')
23382338
2339-
# Crop Image
2339+
# Create a simple zone raster (0 = below median, 1 = above)
2340+
zones_agg = (terrain_agg > terrain_agg.median()).astype(int)
2341+
zones_agg.attrs = terrain_agg.attrs
2342+
zones_agg = zones_agg.rename('Zone')
2343+
2344+
# Crop to keep only the above-median zone
23402345
values_agg = terrain_agg[0:300, 0:250]
2346+
zones_sub = zones_agg[0:300, 0:250]
23412347
cropped_agg = crop(
2342-
zones=terrain_agg,
2348+
zones=zones_sub,
23432349
values=values_agg,
2344-
zones_ids=[0],
2350+
zones_ids=[1],
23452351
)
23462352
23472353
# Edit Attributes

0 commit comments

Comments
 (0)