mikonvergence commited on
Commit
d4b7ad4
1 Parent(s): a5af602

prevent too fast map_to_image calls (returns None)

Browse files
Files changed (1) hide show
  1. helpers/functional.py +6 -3
helpers/functional.py CHANGED
@@ -68,9 +68,12 @@ def cell2row(grid_string, meta_df, return_row = False):
68
 
69
  def map_to_image(map, return_centre=False, return_gridcell=False, l2a=True):
70
 
71
- # 1. get bounds
72
- bbox = map.get_bbox()
73
- center = [(bbox[3]+bbox[1])/2, (bbox[2]+bbox[0])/2]
 
 
 
74
 
75
  # 2. translate coordinate to major-tom tile
76
  rows, cols = grid.latlon2rowcol([center[0]], [center[1]])
 
68
 
69
  def map_to_image(map, return_centre=False, return_gridcell=False, l2a=True):
70
 
71
+ try:
72
+ # 1. get bounds
73
+ bbox = map.get_bbox()
74
+ center = [(bbox[3]+bbox[1])/2, (bbox[2]+bbox[0])/2]
75
+ except:
76
+ return None
77
 
78
  # 2. translate coordinate to major-tom tile
79
  rows, cols = grid.latlon2rowcol([center[0]], [center[1]])