1- import pkg_resources
2- import datetime
31import copy
2+ import datetime
43import numpy as np
4+ import pkg_resources
55
66try :
77 import _richdem
8- except ImportError :
8+ except ImportError as e :
99 print ('COULD NOT LOAD RichDEM ENGINE! NOTHING WILL WORK!' )
10+ raise e
1011
1112try :
1213 from osgeo import gdal
@@ -90,7 +91,7 @@ def rdShow(rda, ignore_colours=[], show=True, axes=True, cmap='gray', vmin=None,
9091
9192 if all_zoom :
9293 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 )
9495 axins .set_ylim (ymin = zymin ,ymax = zymax )
9596 plt .setp (axins .get_xticklabels (), visible = False )
9697 plt .setp (axins .get_yticklabels (), visible = False )
@@ -116,8 +117,8 @@ def rdShow(rda, ignore_colours=[], show=True, axes=True, cmap='gray', vmin=None,
116117
117118class rdarray (np .ndarray ):
118119 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+
121122 if meta_obj is not None :
122123 obj .metadata = copy .deepcopy (getattr (meta_obj , 'metadata' , dict ()))
123124 obj .no_data = copy .deepcopy (getattr (meta_obj , 'no_data' , None ))
@@ -155,7 +156,7 @@ def wrap(self):
155156 dtype = str (self .dtype )
156157 if not dtype in richdem_arrs :
157158 raise Exception ("No equivalent RichDEM datatype." )
158-
159+
159160 rda = richdem_arrs [dtype ](self )
160161
161162 if self .no_data is None :
@@ -170,7 +171,7 @@ def wrap(self):
170171 print ("Warning! No geotransform defined. Choosing a standard one! (Top left cell's top let corner at <0,0>; cells are 1x1.)" )
171172 rda .geotransform = np .array ([0 ,1 ,0 ,0 ,0 ,- 1 ], dtype = 'float64' )
172173
173- return rda
174+ return rda
174175
175176 def copyFromWrapped (self , wrapped ):
176177 self .no_data = wrapped .noData ()
@@ -181,8 +182,8 @@ def copyFromWrapped(self, wrapped):
181182
182183class rd3array (np .ndarray ):
183184 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+
186187 if meta_obj is not None :
187188 obj .metadata = copy .deepcopy (getattr (meta_obj , 'metadata' , dict ()))
188189 obj .no_data = copy .deepcopy (getattr (meta_obj , 'no_data' , None ))
@@ -211,7 +212,7 @@ def wrap(self):
211212 dtype = str (self .dtype )
212213 if not dtype in richdem_arrs :
213214 raise Exception ("No equivalent RichDEM datatype." )
214-
215+
215216 rda = richdem_arrs [dtype ](self )
216217
217218 if self .no_data is None :
@@ -226,7 +227,7 @@ def wrap(self):
226227 print ("Warning! No geotransform defined. Choosing a standard one! (Top left cell's top let corner at <0,0>; cells are 1x1.)" )
227228 rda .geotransform = np .array ([0 ,1 ,0 ,0 ,0 ,- 1 ], dtype = 'float64' )
228229
229- return rda
230+ return rda
230231
231232 def copyFromWrapped (self , wrapped ):
232233 self .no_data = wrapped .noData ()
@@ -250,7 +251,7 @@ def LoadGDAL(filename, no_data=None):
250251
251252 Returns:
252253 A RichDEM array
253- """
254+ """
254255 if not GDAL_AVAILABLE :
255256 raise Exception ("richdem.LoadGDAL() requires GDAL." )
256257
@@ -333,7 +334,7 @@ def FillDepressions(
333334 epsilon (float): If True, an epsilon gradient is imposed to all flat regions.
334335 This ensures that there is always a local gradient.
335336 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.
337338 topology (string): A topology indicator
338339
339340 Returns:
@@ -380,7 +381,7 @@ def BreachDepressions(
380381 Args:
381382 dem (rdarray): An elevation model
382383 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.
384385 topology (string): A topology indicator
385386
386387 Returns:
@@ -420,7 +421,7 @@ def ResolveFlats(
420421 Args:
421422 dem (rdarray): An elevation model
422423 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.
424425
425426 Returns:
426427 DEM modified such that all flats drain.
@@ -456,15 +457,15 @@ def FlowAccumulation(
456457 Args:
457458 dem (rdarray): An elevation model
458459 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
460461 relevant publications for details.
461462 weights (rdarray): Flow accumulation weights to use. This is the
462463 amount of flow generated by each cell. If this is
463464 not provided, each cell will generate 1 unit of
464465 flow.
465466 in_place (bool): If True, then `weights` is modified in place. An
466467 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`
468469 is True.
469470
470471 =================== ============================== ===========================
@@ -565,7 +566,7 @@ def FlowAccumFromProps(
565566 flow.
566567 in_place (bool): If True, then `weights` is modified in place. An
567568 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`
569570 is True.
570571
571572 Returns:
@@ -612,7 +613,7 @@ def FlowProportions(
612613 Args:
613614 dem (rdarray): An elevation model
614615 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
616617 relevant publications for details.
617618
618619 =================== ============================== ===========================
@@ -698,14 +699,14 @@ def TerrainAttribute(
698699 ======================= =========
699700 Method Reference
700701 ======================= =========
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>`_
709710 ======================= =========
710711
711712 Returns:
0 commit comments