-
Notifications
You must be signed in to change notification settings - Fork 8
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
encode shapes #2
Conversation
FYI, I tried to use Mapbox's from wagyu import enums as wEnums
from wagyu.linear_ring import LinearRing as wLinearRing
from wagyu.point import Point as wPoint
from wagyu.polygon import Polygon as wPolygon
from wagyu.wagyu import Wagyu
w = Wagyu()
wext = wPolygon(
[
wLinearRing(
[wPoint(x, y) for x, y in exterior.coords]
)
]
)
w.add_polygon(wext, wEnums.PolygonKind.SUBJECT)
for interior in list(interiors):
wint = wPolygon(
[
wLinearRing(
[wPoint(x, y) for x, y in interior.coords]
)
]
)
w.add_polygon(wint, wEnums.PolygonKind.SUBJECT)
result = w.execute(
wEnums.OperationKind.UNION,
wEnums.FillKind.EVEN_ODD,
wEnums.FillKind.EVEN_ODD
)
for p in result.polygons:
for l in p.linear_rings:
feature.add_ring(len(l))
for p in l.points:
feature.set_point(int(p.x), int(p.y)) |
feature.set_id(v) | ||
|
||
polygon = geometry.shape(p) |
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.
Here we use shapely to split the geometry between interior/exterior
if not polygon.is_valid: | ||
# If the polygon is not valid we use a little trick | ||
polygon = polygon.buffer(0) |
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.
seems that applying a 0 buffer creates a valid geometry (for GEOS)
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.
Read that the other day too, when I had a large polygonize output
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.
so this is still WIP. (see #1)
I've deployed a tiler using https://github.com/developmentseed/titiler-mvt but I'm getting a lot of warnings because the geometry are still invalid.
I may try to use pygeos instead of shapely (and maybe try wagyu again)
ref #1