Skip to content

Commit

Permalink
Update affine translation for web-mercator pyramids (#70)
Browse files Browse the repository at this point in the history
Co-authored-by: Raphael Hagen <[email protected]>
  • Loading branch information
maxrjones and norlandrhagen authored Aug 17, 2023
1 parent 9cfc48c commit 5aee191
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ndpyramid/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Empty file added tests/__init__.py
Empty file.

0 comments on commit 5aee191

Please sign in to comment.