Skip to content
Snippets Groups Projects
Commit 5f140b2b authored by Sara Savanovic Djordjevic's avatar Sara Savanovic Djordjevic
Browse files

update: remove empty subdivisions

parent d76e565d
No related branches found
No related tags found
1 merge request!16Clhp map into main
No preview for this file type
...@@ -52,7 +52,10 @@ def cut_map(self, cursor, lake_name: str, cell_size_in_km: float = 0.5): ...@@ -52,7 +52,10 @@ def cut_map(self, cursor, lake_name: str, cell_size_in_km: float = 0.5):
# Combine the polygon and the grid to form the subdivisions # Combine the polygon and the grid to form the subdivisions
for line in lines: for line in lines:
if line.intersects(polygon): if line.intersects(polygon):
divided_map.append(line.intersection(polygon)) intersection = line.intersection(polygon)
if intersection.is_empty:
continue # Skip if intersection is empty
divided_map.append(intersection)
break # NB test break break # NB test break
...@@ -73,6 +76,10 @@ def cut_map(self, cursor, lake_name: str, cell_size_in_km: float = 0.5): ...@@ -73,6 +76,10 @@ def cut_map(self, cursor, lake_name: str, cell_size_in_km: float = 0.5):
rounded_coordinates.append(rounded_coords) rounded_coordinates.append(rounded_coords)
rounded_tile = Polygon(rounded_coordinates) rounded_tile = Polygon(rounded_coordinates)
geometry = rounded_tile.__geo_interface__
if not geometry['coordinates']:
continue # Skip empty tiles
# Create new feature object # Create new feature object
tile_feature = { tile_feature = {
...@@ -81,7 +88,7 @@ def cut_map(self, cursor, lake_name: str, cell_size_in_km: float = 0.5): ...@@ -81,7 +88,7 @@ def cut_map(self, cursor, lake_name: str, cell_size_in_km: float = 0.5):
'sub_div_id': str(sub_div_id), 'sub_div_id': str(sub_div_id),
'sub_div_center': center 'sub_div_center': center
}, },
'geometry': rounded_tile.__geo_interface__ 'geometry': geometry
} }
# Append new feature oject to list, and increment sub_div_id for next iteration # Append new feature oject to list, and increment sub_div_id for next iteration
features.append(tile_feature) features.append(tile_feature)
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment