Skip to content

Conversation

keewis
Copy link
Member

@keewis keewis commented Aug 29, 2025

Proof-of-concept of how querying by a geometry might work. For now, this is by performing index intersections with the result of geometry rasterization, but index implementations might override that (I'm not aware of any libraries that would have something more efficient, besides compacting to parent cell ids)

@keewis keewis marked this pull request as draft August 29, 2025 15:46
def cell_boundaries(self, cell_ids, backend="shapely"):
raise NotImplementedError()

def rasterize_geometry(self, geom, *, mode=None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name rasterize_geometry is misleading here. This function basically converts an arbitrary geometry to cell ids so I would suggest a name like geometry2cells_ids that is consistent with the other methods of DGGSInfo.

Adding type hints would help too. Is this method intended to support multiple geometries in the future?

The name mode is a bit too generic. Shall we use containment_mode like h3ronpy?

Copy link
Member Author

@keewis keewis Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless you assume "raster" to equal 2D image (I understand "rasterize" as "to discretize onto a grid") I don't see how the name would be misleading. However, you have a point with the consistency argument.

Adding type hints would help too.

We currently don't have type hints on any of the methods, so we'd have to figure out common type hints, first. Maybe in a new PR?

Is this method intended to support multiple geometries in the future?

Potentially, although I'd say querying by a single geometry covers at least 90% of the use-cases for query (and I'm currently not planning to vectorize it).

The name mode is a bit too generic. Shall we use containment_mode like h3ronpy?

Indeed, but containment_mode is also quite the mouthful. I'd argue that in the context of rasterization / conversion to cell ids the word mode is unambiguous, but if that doesn't convince you we can just remove the word mode and use containment="center" or containment="overlap" or something similar, like contained=....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Accessor function that accept polygon and return those cells (with data) that are within the area ?

2 participants