1
- import pkg_resources
2
- import datetime
3
1
import copy
2
+ import datetime
4
3
import numpy as np
4
+ import pkg_resources
5
5
6
6
try :
7
7
import _richdem
8
- except ImportError :
8
+ except ImportError as e :
9
9
print ('COULD NOT LOAD RichDEM ENGINE! NOTHING WILL WORK!' )
10
+ raise e
10
11
11
12
try :
12
13
from osgeo import gdal
@@ -90,7 +91,7 @@ def rdShow(rda, ignore_colours=[], show=True, axes=True, cmap='gray', vmin=None,
90
91
91
92
if all_zoom :
92
93
axins = inset_axes (ax , width = 2 , height = 2 , loc = zloc , borderpad = 0 ) #, bbox_to_anchor=(0.9, -0.05, 1, 1), bbox_transform=ax.transAxes, borderpad=0)
93
- axins .set_xlim (xmin = zxmin ,xmax = zxmax )
94
+ axins .set_xlim (xmin = zxmin ,xmax = zxmax )
94
95
axins .set_ylim (ymin = zymin ,ymax = zymax )
95
96
plt .setp (axins .get_xticklabels (), visible = False )
96
97
plt .setp (axins .get_yticklabels (), visible = False )
@@ -116,8 +117,8 @@ def rdShow(rda, ignore_colours=[], show=True, axes=True, cmap='gray', vmin=None,
116
117
117
118
class rdarray (np .ndarray ):
118
119
def __new__ (cls , array , meta_obj = None , no_data = None , dtype = None , order = None , ** kwargs ):
119
- obj = np .asarray (array , dtype = dtype , order = order ).view (cls )
120
-
120
+ obj = np .asarray (array , dtype = dtype , order = order ).view (cls )
121
+
121
122
if meta_obj is not None :
122
123
obj .metadata = copy .deepcopy (getattr (meta_obj , 'metadata' , dict ()))
123
124
obj .no_data = copy .deepcopy (getattr (meta_obj , 'no_data' , None ))
@@ -155,7 +156,7 @@ def wrap(self):
155
156
dtype = str (self .dtype )
156
157
if not dtype in richdem_arrs :
157
158
raise Exception ("No equivalent RichDEM datatype." )
158
-
159
+
159
160
rda = richdem_arrs [dtype ](self )
160
161
161
162
if self .no_data is None :
@@ -170,7 +171,7 @@ def wrap(self):
170
171
print ("Warning! No geotransform defined. Choosing a standard one! (Top left cell's top let corner at <0,0>; cells are 1x1.)" )
171
172
rda .geotransform = np .array ([0 ,1 ,0 ,0 ,0 ,- 1 ], dtype = 'float64' )
172
173
173
- return rda
174
+ return rda
174
175
175
176
def copyFromWrapped (self , wrapped ):
176
177
self .no_data = wrapped .noData ()
@@ -181,8 +182,8 @@ def copyFromWrapped(self, wrapped):
181
182
182
183
class rd3array (np .ndarray ):
183
184
def __new__ (cls , array , meta_obj = None , no_data = None , order = None , ** kwargs ):
184
- obj = np .asarray (array , dtype = np .float32 , order = order ).view (cls )
185
-
185
+ obj = np .asarray (array , dtype = np .float32 , order = order ).view (cls )
186
+
186
187
if meta_obj is not None :
187
188
obj .metadata = copy .deepcopy (getattr (meta_obj , 'metadata' , dict ()))
188
189
obj .no_data = copy .deepcopy (getattr (meta_obj , 'no_data' , None ))
@@ -211,7 +212,7 @@ def wrap(self):
211
212
dtype = str (self .dtype )
212
213
if not dtype in richdem_arrs :
213
214
raise Exception ("No equivalent RichDEM datatype." )
214
-
215
+
215
216
rda = richdem_arrs [dtype ](self )
216
217
217
218
if self .no_data is None :
@@ -226,7 +227,7 @@ def wrap(self):
226
227
print ("Warning! No geotransform defined. Choosing a standard one! (Top left cell's top let corner at <0,0>; cells are 1x1.)" )
227
228
rda .geotransform = np .array ([0 ,1 ,0 ,0 ,0 ,- 1 ], dtype = 'float64' )
228
229
229
- return rda
230
+ return rda
230
231
231
232
def copyFromWrapped (self , wrapped ):
232
233
self .no_data = wrapped .noData ()
@@ -250,7 +251,7 @@ def LoadGDAL(filename, no_data=None):
250
251
251
252
Returns:
252
253
A RichDEM array
253
- """
254
+ """
254
255
if not GDAL_AVAILABLE :
255
256
raise Exception ("richdem.LoadGDAL() requires GDAL." )
256
257
@@ -333,7 +334,7 @@ def FillDepressions(
333
334
epsilon (float): If True, an epsilon gradient is imposed to all flat regions.
334
335
This ensures that there is always a local gradient.
335
336
in_place (bool): If True, the DEM is modified in place and there is
336
- no return; otherwise, a new, altered DEM is returned.
337
+ no return; otherwise, a new, altered DEM is returned.
337
338
topology (string): A topology indicator
338
339
339
340
Returns:
@@ -380,7 +381,7 @@ def BreachDepressions(
380
381
Args:
381
382
dem (rdarray): An elevation model
382
383
in_place (bool): If True, the DEM is modified in place and there is
383
- no return; otherwise, a new, altered DEM is returned.
384
+ no return; otherwise, a new, altered DEM is returned.
384
385
topology (string): A topology indicator
385
386
386
387
Returns:
@@ -420,7 +421,7 @@ def ResolveFlats(
420
421
Args:
421
422
dem (rdarray): An elevation model
422
423
in_place (bool): If True, the DEM is modified in place and there is
423
- no return; otherwise, a new, altered DEM is returned.
424
+ no return; otherwise, a new, altered DEM is returned.
424
425
425
426
Returns:
426
427
DEM modified such that all flats drain.
@@ -456,15 +457,15 @@ def FlowAccumulation(
456
457
Args:
457
458
dem (rdarray): An elevation model
458
459
method (str): Flow accumulation method to use. (See below.)
459
- exponent (float): Some methods require an exponent; refer to the
460
+ exponent (float): Some methods require an exponent; refer to the
460
461
relevant publications for details.
461
462
weights (rdarray): Flow accumulation weights to use. This is the
462
463
amount of flow generated by each cell. If this is
463
464
not provided, each cell will generate 1 unit of
464
465
flow.
465
466
in_place (bool): If True, then `weights` is modified in place. An
466
467
accumulation matrix is always returned, but it will
467
- just be a view of the modified data if `in_place`
468
+ just be a view of the modified data if `in_place`
468
469
is True.
469
470
470
471
=================== ============================== ===========================
@@ -565,7 +566,7 @@ def FlowAccumFromProps(
565
566
flow.
566
567
in_place (bool): If True, then `weights` is modified in place. An
567
568
accumulation matrix is always returned, but it will
568
- just be a view of the modified data if `in_place`
569
+ just be a view of the modified data if `in_place`
569
570
is True.
570
571
571
572
Returns:
@@ -612,7 +613,7 @@ def FlowProportions(
612
613
Args:
613
614
dem (rdarray): An elevation model
614
615
method (str): Flow accumulation method to use. (See below.)
615
- exponent (float): Some methods require an exponent; refer to the
616
+ exponent (float): Some methods require an exponent; refer to the
616
617
relevant publications for details.
617
618
618
619
=================== ============================== ===========================
@@ -698,14 +699,14 @@ def TerrainAttribute(
698
699
======================= =========
699
700
Method Reference
700
701
======================= =========
701
- slope_riserun `Horn (1981) doi: 10.1109/PROC.1981.11918 <http://dx.doi.org/10.1109/PROC.1981.11918>`_
702
- slope_percentage `Horn (1981) doi: 10.1109/PROC.1981.11918 <http://dx.doi.org/10.1109/PROC.1981.11918>`_
703
- slope_degrees `Horn (1981) doi: 10.1109/PROC.1981.11918 <http://dx.doi.org/10.1109/PROC.1981.11918>`_
704
- slope_radians `Horn (1981) doi: 10.1109/PROC.1981.11918 <http://dx.doi.org/10.1109/PROC.1981.11918>`_
705
- aspect `Horn (1981) doi: 10.1109/PROC.1981.11918 <http://dx.doi.org/10.1109/PROC.1981.11918>`_
706
- curvature `Zevenbergen and Thorne (1987) doi: 10.1002/esp.3290120107 <http://dx.doi.org/10.1002/esp.3290120107>`_
707
- planform_curvature `Zevenbergen and Thorne (1987) doi: 10.1002/esp.3290120107 <http://dx.doi.org/10.1002/esp.3290120107>`_
708
- profile_curvature `Zevenbergen and Thorne (1987) doi: 10.1002/esp.3290120107 <http://dx.doi.org/10.1002/esp.3290120107>`_
702
+ slope_riserun `Horn (1981) doi: 10.1109/PROC.1981.11918 <http://dx.doi.org/10.1109/PROC.1981.11918>`_
703
+ slope_percentage `Horn (1981) doi: 10.1109/PROC.1981.11918 <http://dx.doi.org/10.1109/PROC.1981.11918>`_
704
+ slope_degrees `Horn (1981) doi: 10.1109/PROC.1981.11918 <http://dx.doi.org/10.1109/PROC.1981.11918>`_
705
+ slope_radians `Horn (1981) doi: 10.1109/PROC.1981.11918 <http://dx.doi.org/10.1109/PROC.1981.11918>`_
706
+ aspect `Horn (1981) doi: 10.1109/PROC.1981.11918 <http://dx.doi.org/10.1109/PROC.1981.11918>`_
707
+ curvature `Zevenbergen and Thorne (1987) doi: 10.1002/esp.3290120107 <http://dx.doi.org/10.1002/esp.3290120107>`_
708
+ planform_curvature `Zevenbergen and Thorne (1987) doi: 10.1002/esp.3290120107 <http://dx.doi.org/10.1002/esp.3290120107>`_
709
+ profile_curvature `Zevenbergen and Thorne (1987) doi: 10.1002/esp.3290120107 <http://dx.doi.org/10.1002/esp.3290120107>`_
709
710
======================= =========
710
711
711
712
Returns:
0 commit comments