From 5aee19162408a7946960b9290a4568230517b21c Mon Sep 17 00:00:00 2001 From: Max Jones <14077947+maxrjones@users.noreply.github.com> Date: Thu, 17 Aug 2023 18:17:14 -0400 Subject: [PATCH] Update affine translation for web-mercator pyramids (#70) Co-authored-by: Raphael Hagen --- ndpyramid/common.py | 5 ++++- tests/__init__.py | 0 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 tests/__init__.py diff --git a/ndpyramid/common.py b/ndpyramid/common.py index 9701ad4..4b7976f 100644 --- a/ndpyramid/common.py +++ b/ndpyramid/common.py @@ -22,7 +22,10 @@ def transform(self, *, dim:int) -> rasterio.transform.Affine: if self.name == 'web-mercator': - return rasterio.transform.Affine.translation(-20026376.39, 20048966.10) * rasterio.transform.Affine.scale((20026376.39 * 2) / dim, -(20048966.10 * 2) / dim) + # set up the transformation matrix for the web-mercator projection such that the data conform + # to the slippy-map tiles assumed boundaries. See https://github.com/carbonplan/ndpyramid/pull/70 + # for detailed on calculating the parameters. + return rasterio.transform.Affine.translation(-20037508.342789244, 20037508.342789248) * rasterio.transform.Affine.scale((20037508.342789244 * 2) / dim, -(20037508.342789248 * 2) / dim) elif self.name == 'equidistant-cylindrical': # set up the transformation matrix that maps between the Equidistant Cylindrical projection # and the latitude-longitude projection. The Affine.translation function moves the origin diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29