From c5ea5c6fcc8a0f0e1fc1a3ac69e26e1203ab7edb Mon Sep 17 00:00:00 2001 From: "Soroosh.Mani" Date: Fri, 6 Oct 2023 17:09:32 -0400 Subject: [PATCH] Fix projected bbox issue for big hfun raster --- ocsmesh/hfun/collector.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ocsmesh/hfun/collector.py b/ocsmesh/hfun/collector.py index 574aded9..c17f5ddc 100644 --- a/ocsmesh/hfun/collector.py +++ b/ocsmesh/hfun/collector.py @@ -1964,8 +1964,15 @@ def _create_big_raster(self, out_path: Union[str, Path]) -> Raster: transformer = Transformer.from_crs( 'EPSG:4326', utm_crs, always_xy=True) - box_epsg4326 = box(x0, y0, x1, y1) - poly_utm = ops.transform(transformer.transform, Polygon(box_epsg4326)) + # If it's the full earth, then the spaces are at least 1/2 deg + xs = np.linspace(x0, x1, 720) + ys = np.linspace(y0, y1, 720) + coords = [[x0, y] for y in ys] + coords.extend([[x, y1] for x in xs]) + coords.extend([[x1, y] for y in reversed(ys)]) + coords.extend([[x, y0] for x in reversed(xs)]) + poly_epsg4326 = Polygon(np.array(coords)) + poly_utm = ops.transform(transformer.transform, poly_epsg4326) x0, y0, x1, y1 = poly_utm.bounds worst_res = 0