-
Notifications
You must be signed in to change notification settings - Fork 20
support querying by geometries #169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
def cell_boundaries(self, cell_ids, backend="shapely"): | ||
raise NotImplementedError() | ||
|
||
def rasterize_geometry(self, geom, *, mode=None): |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 usecontainment_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=...
.
changelog.md
api.rst
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)