Skip to content

Commit 5fc1320

Browse files
committed
Add crs and transform for array input
1 parent 2dc971c commit 5fc1320

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

samgeo/common.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -1458,12 +1458,16 @@ def array_to_image(
14581458
array = cv2.imread(array)
14591459
array = cv2.cvtColor(array, cv2.COLOR_BGR2RGB)
14601460

1461-
if output.endswith(".tif") and source is not None:
1462-
with rasterio.open(source) as src:
1463-
crs = src.crs
1464-
transform = src.transform
1465-
if compress is None:
1466-
compress = src.compression
1461+
if output.endswith(".tif"):
1462+
if source is not None:
1463+
with rasterio.open(source) as src:
1464+
crs = src.crs
1465+
transform = src.transform
1466+
if compress is None:
1467+
compress = src.compression
1468+
else:
1469+
crs = kwargs.get("crs", None)
1470+
transform = kwargs.get("transform", None)
14671471

14681472
# Determine the minimum and maximum values in the array
14691473

0 commit comments

Comments
 (0)