xarray-contrib / xvec

Vector data cubes for Xarray
https://xvec.readthedocs.io
MIT License
101 stars 9 forks source link

Accessor #10

Closed martinfleis closed 1 year ago

martinfleis commented 1 year ago

In some occasions (#4 #5) we mentioned that the accessor would be a nice addition here and could eventually expose a lot of what shapely/geopandas now offer.

What would be the ideal name, that is not ambiguous and minimises a risk of a conflict with another accessor by another package?

We mentioned .vec but that may not be the most intuitive. .geo is taken by geoxarray and does apply to both raster and vector anyway. What about using .geom indicating an operation on geometry? That would also be consistent with GeometryIndex.

benbovy commented 1 year ago

Ideally it should also minimize the risk of a conflict with coordinate and variable names.

There's no real consensus regarding how to name xarray extension packages and accessors, it varies from one package to another.

If the package aims to provide a unique accessor, I'd tend to choose the same name for both the package and the accessor as it is easier to remember. I also like this pattern: xyz-xarray (with or without -) for the package name and xyz for the accessor name (like cf-xarray, pint-xarray and rioxarray). I don't have strong opinion, though.

martinfleis commented 1 year ago

Ideally it should also minimize the risk of a conflict with coordinate and variable names.

True. That eliminates .geom as that will be one of the first choices for many when using shapely geoms as coordinates.

We can also consider following xoak's model and use .xvec as an accessor name. That is both unambiguous and quite unique as a string to minimise the potential conflict.

benbovy commented 1 year ago

use .xvec as an accessor name

+1

benbovy commented 1 year ago

It may be too premature, but I'm also wondering how would co-exist geometry and geography coordinates in a Dataset / DataArray?

Should we reuse the same xvec accessor? If yes, maybe have two geom_coords and geog_coords properties returning geometry / geography coordinates, respectively?

With the suggested API in https://github.com/martinfleis/xvec/pull/11#issuecomment-1334964188, any method called with coords=None may raise an error if both geometry and geography coordinate are found...

martinfleis commented 1 year ago

I would try to match the behaviour of geopandas in relation to geometry/geography and that is not defined yet.

We can potentially raise for unsupported ops when geography is passed, I assume that geopandas will do that as well.