Skip to content

Commit

Permalink
fix bug in write_bbox() (#2316)
Browse files Browse the repository at this point in the history
Fix args passed to rasterio.transform.from_origin() in write_bbox()
  • Loading branch information
AdeelH authored Feb 21, 2025
1 parent 9c896e9 commit b2b85db
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion rastervision_core/rastervision/core/data/utils/rasterio.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def write_bbox(path: str, arr: np.ndarray, bbox: Box, crs_wkt: str, **kwargs):
else:
h_arr, w_arr, num_channels = arr.shape
h_bbox, w_bbox = bbox.size
resolution = h_bbox / h_arr, w_bbox / w_arr
resolution = w_bbox / w_arr, h_bbox / h_arr
transform = from_origin(bbox.xmin, bbox.ymax, *resolution)
out_profile = dict(
driver='GTiff',
Expand Down
4 changes: 2 additions & 2 deletions tests/core/data/utils/test_rasterio.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def test_write_bbox(self):
bbox = Box(ymin=48.815, xmin=2.224, ymax=48.902, xmax=2.469)
crs_wkt = pyproj.CRS('epsg:4326').to_wkt()
r = bbox.width / bbox.height
arr1 = np.zeros((100, int(100 * r)))
arr2 = np.zeros((100, int(100 * r), 4))
arr1 = np.zeros((50, int(100 * r)))
arr2 = np.zeros((50, int(100 * r), 4))
with get_tmp_dir() as tmp_dir:
geotiff_path = join(tmp_dir, 'test.geotiff')
write_bbox(geotiff_path, arr1, bbox=bbox, crs_wkt=crs_wkt)
Expand Down

0 comments on commit b2b85db

Please sign in to comment.