xarray-contrib / xdggs

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

cell hierarchy operations #38

Open keewis opened 8 months ago

keewis commented 8 months ago

We've mostly been working with hierarchical DGGS, so it might be good to have functions that allow working with that hierarchy. Those would be (I can only think of a single one right now, but I'm sure there's more):

strobpr commented 5 months ago

All DGGSs are hierarchical, below is a list of query functions a DGGS API has to provide (from ISO 19170/OGC AS Topic 21):

8.3.3.2. Summary of operations in ZoneQuery

The following operations have the same topological meaning as their equivalent operations in ISO 19107:2019 Geometry::Query2D and Geometry::Query3D: distance, contains, crosses, disjoint, equals, intersects, overlaps, touches, within, withinDistance, difference, intersection, symDifference, union, and relate.

image

Figure 15 — Examples of parent, child, and sibling query operations

EXAMPLES

Parent, sibling and child queries for zone 40:
40.parent() returns {4}
40.sibling(inheritID=true) returns {40, 41, 42, 43}
40.sibling() returns {13, 22, 23, 31, 40, 41, 42, 43}
40.child(inheritID=true) returns {400, 401, 402, 403}

Parent, sibling and child tests for zone 40:
40.parentOf(400) returns true
40.siblingOf(41) returns true
40.siblingOf(31, inheritID=true) returns false
40.siblingOf(41) returns true
40.childOf(4) returns true

Parent and child tests for zones 31 and 33 with multiple parents:
31.childOf(4, inheritID=true) returns false
31.childOf(4) returns true
31.parent(inheritID=true) returns {3}
31.parent() returns {3, 4}
33.parent() returns {3, 4, 5, 6}

Parent and child queries with levels set to a value greater than 1:
400.parent(inheritID=true, level=2) returns {40, 4}
4.child(inheritID=true, 2) returns {40, 41, 42, 43, 400, 401, 402, 403, 410, 411, 412, 413, 420, 421, 422, 423, 430, 431, 432, 433}
400.sibling(inheritID=true, levels=2) returns {400, 401, 402, 403, 410, 411, 412, 413, 420, 421, 422, 423, 430, 431, 432, 433}
While some of these results extend to zones that are not drawn in the figure, the location indicated by their zonal identifier should be readily apparent from the pattern.

NOTE In all examples the optional parameters inheritID and levels take their default values of false and 1 respectively, unless they are specified. Since these are two-dimensional examples without any depth or time, projectTo has no influence.

Further query and analysis functions may then be applied to the returned data through additional software bindings. This abstract specification does not specify any requirements for the binding or implementation of further, extension, query or analytic functions.

Figure 16 — Components of Topological Zonal Query Functions module

benbovy commented 3 months ago

See also #18.