Closed lubojr closed 1 year ago
Also, a 0
width buffer might help as well: https://stackoverflow.com/a/56814595
I agree that current edit can be a bit too invasive.
For the exact issue that this PR was targeting (hourglass like footprint with switched point order in source) - Width(0) buffer did not solve the problem, it removed one of the points of the polygon, effectively creating a triangle. The solution of hull creates expected result (but only in this case, I agree). I did not test make_valid, but I assume it will create the same result.
This PR is put on hold as draft currently and not being urgent to push to master.
The operation attempting to fix footprint will be configurable, default being NO-OP
, as all other operations are changing the footprint.
There is a pygeos function we could try here as well: https://pygeos.readthedocs.io/en/stable/constructive.html?highlight=make%20valid#pygeos.constructive.make_valid
When using this make_valid
function to make an "hourglass" polygon valid, this turns it into two triangles (multipolygon)
>>> from pygeos import make_valid, Geometry, to_wkt
>>> out = make_valid(Geometry("POLYGON((0 0, 0 1, 1 0, 1 1, 0 0))"))
>>> to_wkt(out)
'MULTIPOLYGON (((0.5 0.5, 0 0, 0 1, 0.5 0.5)), ((1 0, 0.5 0.5, 1 1, 1 0)))'
>>>
So this is actually not what we want.
Todo -> move to registrar as an opt-in functionality.
There is a pygeos function we could try here as well: https://pygeos.readthedocs.io/en/stable/constructive.html?highlight=make%20valid#pygeos.constructive.make_valid