Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _mask_rasterize_split(lon, lat, polygons, numbers, fill=np.NaN, **kwargs):
split_point = _find_splitpoint(lon)
lon_l, lon_r = lon[:split_point], lon[split_point:]
mask_l = _mask_rasterize(lon_l, lat, polygons, numbers=numbers)
mask_r = _mask_rasterize(lon_r, lat, polygons, numbers=numbers)
return np.hstack((mask_l, mask_r))
def _mask_rasterize_flip(lon, lat, polygons, numbers, fill=np.NaN, **kwargs):
split_point = _find_splitpoint(lon)
flipped_lon = np.hstack((lon[split_point:], lon[:split_point]))
mask = _mask_rasterize(flipped_lon, lat, polygons, numbers=numbers)
# revert the mask
return np.hstack((mask[:, split_point:], mask[:, :split_point]))
def _determine_method(lon, lat):
""" find method to be used -> prefers faster methods"""
if equally_spaced(lon, lat):
return "rasterize"
if _equally_spaced_on_split_lon(lon) and equally_spaced(lat):
split_point = _find_splitpoint(lon)
flipped_lon = np.hstack((lon[split_point:], lon[:split_point]))
if equally_spaced(flipped_lon):
return "rasterize_flip"
else:
return "rasterize_split"
return "shapely"