xarray-contrib / xdggs

Xarray extension for DGGS
Apache License 2.0
54 stars 9 forks source link

add support for querying by geometry #9

Closed keewis closed 9 months ago

keewis commented 10 months ago

No H3 support, and uses shapely.Polygon which might not actually be suitable for this.

benbovy commented 10 months ago

About the name of the methods, what about this pattern?

I changed my mind in #20 :). query is consistent with Xvec.

However, I wonder if we shouldn't focus first on methods for extracting cell geometry (#10) or for converting DGGS data cubes into vector data cubes (using xvec). Xvec already implements querying by geometry in a very generic way.

There may be more optimal ways to perform spatial queries on DGGS data than considering it just like any arbitrary vector data? From what I've seen, it looks like DGGS tools are doing things internally that are quite similar to what Xvec does (via shapely / GEOS's rtree).

keewis commented 10 months ago

well, if that's the case then we should probably make use of xvec instead. However, that would mean that we'd have to have query add the boundaries coordinate and index it if it doesn't exist already (or error, but in that case we might as well not provide it)

benbovy commented 10 months ago

However, that would mean that we'd have to have query add the boundaries coordinate and index it if it doesn't exist already (or error, but in that case we might as well not provide it)

Or do not support any spatial indexing in DGGS for now (no Dataset.dggs.query()) and recommend users to do something like below?

# convert to vector data cube
# (automatically set a xvec.GeometryIndex so it is ready for use)
vds = ds.dggs.to_polygons()

# spatial query
vds.xvec.query(...)

That doesn't look like much extra work on the user side.

EDIT: we might as well not provide it as you say.

keewis commented 10 months ago

okay, I agree with not doing this for now until we have evidence that this is possible for every DGGS using just the cell id

tinaok commented 9 months ago

I do want to select the interest area in polygon for my use-case.

benbovy commented 9 months ago

I do want to select the interest area in polygon for my use-case.

Yes, the idea is to support that via Xvec (after converting the DGGS data cube to a polygon vector data cube) and see later if there is a need and/or a more optimal way to support that in xdggs.

keewis commented 9 months ago

it does sound like we're not going to pursue this way of implementing the geometry search any further, so let's close this?

benbovy commented 9 months ago

Yes we can close this I think, and maybe re-open it later if needed.