Skip to content

Conversation

@dbaston
Copy link
Member

@dbaston dbaston commented Feb 4, 2025

As discussed in #967, adds functions for:
(1) subdividing a geometry by a rectangular grid
(2) computing the fraction of each cell in a grid that is covered by a polygon

Performance in the included benchmark is 1-3 orders of magnitude faster than repeated calls to Geometry::intersection

image

Code was adapted and pared down from https://github.com/isciences/exactextract

@dbaston dbaston added the Enhancement New feature or feature improvement. label Feb 4, 2025
@dbaston dbaston marked this pull request as draft February 4, 2025 17:07
@dbaston dbaston force-pushed the grid-intersection branch from 96f73a4 to 843eb01 Compare July 9, 2025 12:52
@dbaston dbaston marked this pull request as ready for review July 10, 2025 18:05
@pramsey
Copy link
Member

pramsey commented Jul 11, 2025

This looks very exciting, I'm fine w/ the CAPI and not qualified to judge the implementation. The tests look good, maybe see if any of the codecov suggestions for complete coverage are easy to knock off.

@dbaston dbaston force-pushed the grid-intersection branch 7 times, most recently from c2d9c93 to 26b08ae Compare July 13, 2025 15:25
@dbaston
Copy link
Member Author

dbaston commented Jul 16, 2025

Still working through a couple of minor issues with this. I think it could go in the beta, I'm not seeing anything I can't resolve before release.

@dbaston dbaston force-pushed the grid-intersection branch 2 times, most recently from a19511a to 15a7a71 Compare August 10, 2025 20:06
@dbaston dbaston force-pushed the grid-intersection branch from 43bcd9b to 37fec59 Compare August 27, 2025 12:59
@dbaston
Copy link
Member Author

dbaston commented Aug 27, 2025

Current status: this produces valid polygons in all cases that I've tested, but the polygons do not necessarily form a valid coverage if polygon boundaries follow grid cell boundaries. Here is an example:

image

Subdivided to produce:

image

In this case, some of the fully interior polygons are generated as squares without redundant nodes along their edges. As a result, the polygons do not form a valid coverage. Because the missing nodes may only be on a horizontal or vertical edge, they do not cause an overlap or gap.

@dbaston dbaston force-pushed the grid-intersection branch from 37fec59 to d48797a Compare August 27, 2025 13:07
@theroggy
Copy link

In this case, some of the fully interior polygons are generated as squares without redundant nodes along their edges. As a result, the polygons do not form a valid coverage.

Because the missing nodes may only be on a horizontal or vertical edge, they do not cause an overlap or gap.

It isn't really clear to me where the missing nodes are, but this last sentence is an important nuance indeed... because of this overlay operations should not cause slivers,... so at least for my use cases, it not being a valid coverage is not a problem.

@dbaston
Copy link
Member Author

dbaston commented Nov 23, 2025

It isn't really clear to me where the missing nodes are,

I mean that polygon "A" should have a node at the location pointed to by the arrow. If it does not have a node at this location there will be no gaps or overlaps between adjacent polygons, but the polygons will still not be considered to form a valid coverage.

image

Either way, I believe all issues in this category have now been addressed.

@dbaston dbaston merged commit c0b00fc into libgeos:main Nov 27, 2025
26 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement New feature or feature improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants