You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Using xarray to make transformations less ambiguous #47
Cost/benefit analysis of using xarray to annotate the dimensions of vectors (see code examples below).
Pro:
would make transformations less ambiguous
possibility to apply transformations to points of any shapes, for instance (n, 2) and (2, n).
Cons:
extra verbosity for the use
Current approach: initially I am using numpy arrays for the vectors describing points and performing a shape check (e.g. 2D translations can't be applied to a set of points stored as a numpy array of shape (2, n), but only with a shape (n, 2) (excluding edge cases like n=2).
Later we can discuss the preferred approach.
Code examples from @ivirshup of using xarray.DataArray to annotate the dimensions of vectors.
import xarray as xr
da = xr.DataArray([1,2,3], coords={"dim": ["x", "y", "z"]})
da.sel({"dim": "x"})
<xarray.DataArray ()>
array(1)
Coordinates:
dim <U1 'x'
Activity
ivirshup commentedon Dec 12, 2022
How could this interact with shapely/ geopandas? It looks like geopandas and shapely effectively hardcode x, y, z
LucaMarconato commentedon Dec 12, 2022
Good catch. I'll think about it. I think that #39) is also related (more details in the linked issue).
LucaMarconato commentedon Feb 13, 2023
The transformations are now using this approach internally to apply the transformations.