Closed j08lue closed 1 week ago
I see we have some code in TiTiler-Xarray that makes sure datasets conform to the format we expect, e.g.
if crs == "epsg:4326" and (da.x > 180).any():
# Adjust the longitude coordinates to the -180 to 180 range
da = da.assign_coords(x=(da.x + 180) % 360 - 180)
# Sort the dataset by the updated longitude coordinates
da = da.sortby(da.x)
I guess we should at least add some checks to the XarrayReader, though, so it fails better?
that seems reasonable
I created an
rio_tiler.io.xarray.XarrayReader
for a dataset that has longitude range 200 to 330 degrees East (which is not uncommon in NetCDF datasets) and tried to get a global tile at zoom level 0.That would fail, saying the tile was out of bounds.
Once I subtracted 360 to get the longitudes into the -180, 180 range, it worked.
Should we handle datasets with wrapping longitude axes better in
XarrayReader
? Or document the tight criteria that files need to fulfill to work?Here is a minimal example: https://gist.github.com/j08lue/6ec9ecc2a853e499e4fca98d8aa5fb78
The gist:
fails with