Skip to content

Commit

Permalink
fix: corriger la géométrie de certaines zones
Browse files Browse the repository at this point in the history
  • Loading branch information
dhdaines committed Dec 8, 2023
1 parent 0c985a1 commit 178f87f
Show file tree
Hide file tree
Showing 2 changed files with 135,779 additions and 144 deletions.
17 changes: 17 additions & 0 deletions repair_zonage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env python3

"""
Réparer les polygones invalides dans le fichier de zonage.
"""

from shapely.validation import explain_validity, make_valid
import geopandas

zonage = geopandas.read_file("zonalda/zonage.geojson")
invalid = zonage.loc[~zonage.geometry.is_valid]
for idx, zone in invalid.iterrows():
print(idx, explain_validity(zone.geometry))
fixed_zone = make_valid(zone.geometry)
zonage.geometry.iloc[idx] = fixed_zone
with open("zonalda/zonage-valid.geojson", "wt") as outfh:
outfh.write(zonage.to_json(indent=2, ensure_ascii=False))
Loading

0 comments on commit 178f87f

Please sign in to comment.