File tree Expand file tree Collapse file tree 1 file changed +15
-8
lines changed
Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -103,18 +103,25 @@ def is_geo_coords(lat, lon):
103103 test : bool
104104 True if lat/lon ranges seem to be in the geographic coordinates range, otherwise False.
105105 """
106- lat = (
107- np .asarray (lat ) if np .asarray (lat ).size > 0 else np .array ([0 ])
108- ) # replace empty arrays with zeros to avoid errors
109- lon = (
110- np .array (lon ) if np .array (lon ).size > 0 else np .array ([0 ])
111- ) # by default, we consider empty arrays as valid geo coords
106+ lat = np .asarray (lat )
107+ lon = np .array (lon )
108+ # by default, we consider empty arrays and all-nans arrays as valid geo coords
109+ if lat .size == 0 or np .all (np .isnan (lat )):
110+ lat = np .array ([0 ])
111+ if lon .size == 0 or np .all (np .isnan (lon )):
112+ lon = np .array ([0 ])
112113
113114 # Check if latitude is within -90 to 90 and longitude is within -540 to 540
114115 # and extent are smaller than 180 and 360 respectively
115116 return (
116- lat .min () >= - 91 and lat .max () <= 91 and lon .min () >= - 541 and lon .max () <= 541
117- ) and ((lat .max () - lat .min ()) <= 181 and ((lon .max () - lon .min ()) <= 541 ))
117+ np .nanmin (lat ) >= - 91
118+ and np .nanmax (lat ) <= 91
119+ and np .nanmin (lon ) >= - 541
120+ and np .nanmax (lon ) <= 541
121+ ) and (
122+ (np .nanmax (lat ) - np .nanmin (lat )) <= 181
123+ and ((np .nanmax (lon ) - np .nanmin (lon )) <= 541 )
124+ )
118125
119126
120127def check_if_geo_coords (lat , lon ):
You can’t perform that action at this time.
0 commit comments