File tree Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Original file line number Diff line number Diff line change 24
24
# Some planetary datasets use planetocentric or planetographic projections — still usable for 2D mapping.
25
25
26
26
27
+ import sys
28
+
29
+ def require_module (name , alias = None , install_hint = None ):
30
+ try :
31
+ module = __import__ (name )
32
+ if alias :
33
+ globals ()[alias ] = module
34
+ else :
35
+ globals ()[name ] = module
36
+ except ImportError :
37
+ print (f"Error: This script requires the '{ name } ' package." )
38
+ if install_hint :
39
+ print (f"Install it using: { install_hint } " )
40
+ else :
41
+ print (f"Try: pip install { name } " )
42
+ sys .exit (1 )
43
+
44
+ # Require necessary modules
45
+ require_module ('rasterio' , install_hint = 'pip install rasterio' )
46
+ require_module ('numpy' , alias = 'np' , install_hint = 'pip install numpy' )
47
+
48
+ # Standard, should always be available:
27
49
import argparse
28
- import numpy as np
29
- import rasterio
30
- from rasterio .enums import Resampling
31
50
import json
32
51
33
52
# ----------------------------
You can’t perform that action at this time.
0 commit comments