def bbox_indices(self, bbox, shape, precision=7):
"""
Return row and column coordinates of a bounding box at a
given cellsize.
Parameters
----------
bbox : tuple of floats or ints (length 4)
bbox of new data.
shape : tuple of ints (length 2)
The shape of the 2D array (rows, columns).
precision : int
Precision to use when matching geographic coordinates.
"""
rows = np.around(np.linspace(bbox[1], bbox[3],
shape[0], endpoint=False)[::-1], precision)
cols = np.around(np.linspace(bbox[0], bbox[2],
shape[1], endpoint=False), precision)
return rows, cols
评论列表
文章目录