Skip to content

Commit b2b85db

Browse files
authored
fix bug in write_bbox() (#2316)
Fix args passed to rasterio.transform.from_origin() in write_bbox()
1 parent 9c896e9 commit b2b85db

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

rastervision_core/rastervision/core/data/utils/rasterio.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def write_bbox(path: str, arr: np.ndarray, bbox: Box, crs_wkt: str, **kwargs):
5959
else:
6060
h_arr, w_arr, num_channels = arr.shape
6161
h_bbox, w_bbox = bbox.size
62-
resolution = h_bbox / h_arr, w_bbox / w_arr
62+
resolution = w_bbox / w_arr, h_bbox / h_arr
6363
transform = from_origin(bbox.xmin, bbox.ymax, *resolution)
6464
out_profile = dict(
6565
driver='GTiff',

tests/core/data/utils/test_rasterio.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ def test_write_bbox(self):
1818
bbox = Box(ymin=48.815, xmin=2.224, ymax=48.902, xmax=2.469)
1919
crs_wkt = pyproj.CRS('epsg:4326').to_wkt()
2020
r = bbox.width / bbox.height
21-
arr1 = np.zeros((100, int(100 * r)))
22-
arr2 = np.zeros((100, int(100 * r), 4))
21+
arr1 = np.zeros((50, int(100 * r)))
22+
arr2 = np.zeros((50, int(100 * r), 4))
2323
with get_tmp_dir() as tmp_dir:
2424
geotiff_path = join(tmp_dir, 'test.geotiff')
2525
write_bbox(geotiff_path, arr1, bbox=bbox, crs_wkt=crs_wkt)

0 commit comments

Comments
 (0)