try with shapely.set_precision(...mode="keep_collpased")

This commit is contained in:
kba 2025-11-06 11:55:40 +01:00
parent 0d84e7da16
commit d224b0f7e8

View file

@ -357,7 +357,7 @@ def join_polygons(polygons: Sequence[Polygon], scale=20) -> Polygon:
assert jointp.geom_type == 'Polygon', jointp.wkt assert jointp.geom_type == 'Polygon', jointp.wkt
# follow-up calculations will necessarily be integer; # follow-up calculations will necessarily be integer;
# so anticipate rounding here and then ensure validity # so anticipate rounding here and then ensure validity
jointp2 = set_precision(jointp, 1.0) jointp2 = set_precision(jointp, 1.0, mode="keep_collapsed")
if jointp2.geom_type != 'Polygon' or not jointp2.is_valid: if jointp2.geom_type != 'Polygon' or not jointp2.is_valid:
jointp2 = Polygon(np.round(jointp.exterior.coords)) jointp2 = Polygon(np.round(jointp.exterior.coords))
jointp2 = make_valid(jointp2) jointp2 = make_valid(jointp2)