Skip to content

Is there an easy way to check if a cell is inside a LatLngPoly? #927

Answered by dfellis
luizamfsantos asked this question in Q&A
Discussion options

You must be logged in to vote

If you want to check containment of an individual cell within a polygon, just using cellToLatLng and then using a normal point-in-polygon call with that point would be equivalent based on how polygonToCells generates the set of cells returned.

If you want full containment or any overlapping containment (with the assumption that the polygon feature details are not smaller than an individual cell), you can use cellToBoundary to get the borders of the cell in question, and then test all of those points with the point-in-polygon algorithm, where full containment requires all points to be in, and any overlap requires at least one.

If the set of polygons is relatively static and smaller in numb…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by luizamfsantos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants