carbonplan / ndpyramid

A small utility for generating ND array pyramids using Xarray and Zarr.
https://ndpyramid.readthedocs.io
MIT License
91 stars 6 forks source link

Support for custom tiling approaches in ndpyramid #92

Open maxrjones opened 8 months ago

maxrjones commented 8 months ago

Overview of tiling schemes in ndpyramid

Most of the CarbonPlan mapping toolkit is based on the map zoom level quadtree pattern where the number of tiles at a given zoom level corresponds to 2zoom and each zoom level covers the entire globe, as described in the schema docs. ndpyramid currently supports EPSG:4326 and EPSG:3857 through the pyramid_reproject and pyramid_regrid functions, which correspond to the global-geodetic and global-mercator profiles in the Tile Map Service OGC Specification, with the exception that the EPSG:4326 pyramids have one tile at zoom level 0, whereas the global-geodetic profile has two.

The pyramid_coarsen function instead generates pyramids with each zoom level representing a decimation relative to the base resolution. In the case in which each zoom level is a decimation of 2zoom relative to the base resolution, this corresponds to the local profile in the Tile Map Service OGC Specification. These pyramid levels do not align with standard web map zoom levels, can be in any projection, and are not supported by @carbonplan/maps.

The gdal COG driver also supports a custom tiling scheme, which allows setting the target projection, resolution, and extent independently. This is not currently supported in ndpyramid.

Open questions:

  1. Should ndpyramid support the custom tiling scheme? What would be the benefit of this feature?
  2. Would there be substantial benefits of @carbonplan/maps supporting a local or decimation pyramid scheme?

A separate issue is how to best represent the difference between these schemes in the multiscales metadata. Currently the representation would need to be inferred by the method and kwargs attributes, which seems difficult to interpret.

Benefits of global tiling scheme

Benefits of local tiling scheme

maxrjones commented 8 months ago

FYI @katamartin and @freeman-lab on this issue following-up on our zoom discussion. I think the storage differences between the local and global schemes are interesting to keep in mind, but may not be a major consideration for smaller projects.

maxrjones commented 8 months ago

Vincent Sarago suggested that we should follow the OGC TMS 2.0 standard. A key difference so far is that ndpyramid's EPSG:4326 reprojection produces one tile at zoom level 0 rather than two as defined in the World CRS 84 Quad.

maxrjones commented 6 months ago

https://github.com/zarr-developers/geozarr-spec/pull/44 details how the TMS 2.0 standard could be used in GeoZarr. It would be great to test out that approach in ndpyramid, and discuss the implications for carbonplan/maps.