Skip to content

Commit f1e6303

Browse files
committed
fix: preserve parent coordinate dtype in overview levels
TiTiler requires coordinate dtypes to match between parent and child groups. Previously np.linspace() always returned float64, causing alignment errors when parent coordinates were int64. Now reads parent dtype and casts overview coordinates accordingly. Fixes: group /measurements/reflectance/r10m/1 is not aligned error
1 parent 055f090 commit f1e6303

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/eopf_geozarr/conversion/geozarr.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -935,10 +935,14 @@ def create_overview_dataset_all_vars(
935935
# Calculate the transform for this overview level
936936
overview_transform = rasterio.transform.from_bounds(*native_bounds, width, height)
937937

938-
# Create coordinate arrays
938+
# Determine coordinate dtype from parent dataset to maintain alignment
939+
parent_x_dtype = ds.coords["x"].dtype if "x" in ds.coords else np.float64
940+
parent_y_dtype = ds.coords["y"].dtype if "y" in ds.coords else np.float64
941+
942+
# Create coordinate arrays preserving parent dtype
939943
left, bottom, right, top = native_bounds
940-
x_coords = np.linspace(left, right, width, endpoint=False)
941-
y_coords = np.linspace(top, bottom, height, endpoint=False)
944+
x_coords = np.linspace(left, right, width, endpoint=False, dtype=parent_x_dtype)
945+
y_coords = np.linspace(top, bottom, height, endpoint=False, dtype=parent_y_dtype)
942946

943947
# Check if we're dealing with geographic coordinates (EPSG:4326)
944948
if native_crs and native_crs.to_epsg() == 4326:

0 commit comments

Comments
 (0)