Skip to content
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

Get the exterior of cell union #363

Closed
iskandari opened this issue May 2, 2024 · 2 comments
Closed

Get the exterior of cell union #363

iskandari opened this issue May 2, 2024 · 2 comments

Comments

@iskandari
Copy link

iskandari commented May 2, 2024

Given a union of s2 cells that originate from GetCovering(), is it possible using the s2 API (in python or go) to obtain the exterior geometry or loop of this union (assuming the union forms a polygon) ?

s2_cells = coverer.GetCovering(s2_polygon)
print(s2_cells[0:5])

(<s2geometry.S2CellId; proxy of <Swig Object of type 'S2CellId *' at 0x12fcf3120> >, <s2geometry.S2CellId; proxy of <Swig Object of type 'S2CellId *' at 0x12fcf2e80> >, <s2geometry.S2CellId; proxy of <Swig Object of type 'S2CellId *' at 0x12fcf3690> >, <s2geometry.S2CellId; proxy of <Swig Object of type 'S2CellId *' at 0x12fcf3d80> >, <s2geometry.S2CellId; proxy of <Swig Object of type 'S2CellId *' at 0x12fcf2940> >)

cell_union.Init([cell.id() for cell in s2_cells])

#unsure where to go from here

I have tried with a buffering operation but it seems only to return True/False

opts = s2.S2BufferOperationOptions()
opts.set_buffer_radius(s2.S1Angle.Degrees(0.001))
result = s2.S2Polygon()
layer = s2.S2PolygonLayer(result)
op = s2.S2BufferOperation(layer, opts)
for cell in s2_cells:
    op.AddPolygon(s2.S2Polygon(s2.S2Cell(cell)))
op.Build()
#True

I love using s2 and would be grateful for any suggestions on how to obtain the exterior of a covering!

@smcallis
Copy link
Collaborator

smcallis commented May 2, 2024 via email

@iskandari
Copy link
Author

iskandari commented May 2, 2024

Looking for a pythonic solution but will try the C++ method!

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

No branches or pull requests

2 participants