Open robintw opened 2 years ago
From this code: https://github.com/davidbrochart/xarray_leaflet/blob/36adfa464c4ede34c3df019474a0f9d72d2877c6/xarray_leaflet/xarray_leaflet.py#L114-L129 I think that only WGS84 is supported if it's a dynamic map, but static maps should support projections supported by Leaflet. Also, there is an example with a custom projection: https://github.com/davidbrochart/xarray_leaflet/blob/main/examples/custom_projection.ipynb
From what I can see from looking at that bit of code, and playing with the library, it seems that code only deals with a map that is in a different projection, not a DataArray that's in a different projection.
Looking at https://github.com/davidbrochart/xarray_leaflet/blob/main/xarray_leaflet/xarray_leaflet.py#L340, it seems that the raw lat-lon values of the tile boundaries are used to index the DataArray (and the same again at https://github.com/davidbrochart/xarray_leaflet/blob/main/xarray_leaflet/xarray_leaflet.py#L367) - and obviously this won't work if the xarray is indexed in lat-lon.
The reprojection that happens later (https://github.com/davidbrochart/xarray_leaflet/blob/main/xarray_leaflet/xarray_leaflet.py#L387) seems to be reprojecting to the projection of the map object.
I think this might be fixable relatively easily, if we can reproject to WGS84 before we do the subsetting - I'll do some experimenting and let you know how I get on.
hey @robintw, if you don't mind building off an unmerged PR in ipyleaflet, it's not too difficult to use imageservice layers with rioxarray. I found that it was easier when I was tinkering around on a project to just dynamically create images versus trying to do dynamically create projected tiles. Probably would be better in the long run to get the tiles working but this wasn't too bad :shrug:
I'm trying to use xarray_leaflet to display an image that I've loaded via rioxarray. The image isn't in WGS84 projection (it's in a UK-based projection). It doesn't appear on the map, so I've been looking into the code.
In
_get_tiles()
the DataArray seems to be indexed by the lat/lon co-ordinates of a mercantile tile.Does this mean that xarray_leaflet does not currently support working with DataArrays that are not indexed in lat/lon co-ordinates? I notice that the examples use large-scale global datasets that seem to be in WGS84.