11from typing import List
2- from typing import Tuple
32from typing import Union
43
54import shapely
1110def split_region_in_utm_tiles (
1211 region : Union [shapely .geometry .Polygon , shapely .geometry .MultiPolygon ],
1312 crs : CRS = CRS .WGS84 ,
14- bbox_size : Tuple [ int , int ] = ( 10000 , 10000 ) ,
13+ bbox_size : int = 10000 ,
1514 ** kwargs ,
1615) -> List [Tile ]:
1716 """Split a given geometry in squares measured in meters.
1817 It splits the region in utm grid and the convert back to given crs.
1918
2019 Args:
2120 region (UnionList[shapely.geometry.Polygon, shapely.geometry.MultiPolygon]): The region to split from
22- bbox_size (Tuple[ int, int] ): square bbox in meters
21+ bbox_size (int): bbox size in meters
2322
2423 Returns:
2524 [List[Tile]]: The Tiles representing each of the boxes
@@ -28,20 +27,15 @@ def split_region_in_utm_tiles(
2827 crs_bboxes = utm_splitter .get_bbox_list ()
2928 info_bboxes = utm_splitter .get_info_list ()
3029
31- assert (
32- bbox_size [0 ] == bbox_size [1 ]
33- ), "bbox_size sides should be equal size, i.e. square"
34- size = bbox_size [0 ]
35-
3630 tiles = []
3731 for info , box in zip (info_bboxes , crs_bboxes ):
3832 # tile ids are globally unique and take the format shown below
3933 zone = info ["utm_zone" ]
4034 row = info ["utm_row" ]
41- x , y = (int (v / size ) for v in box .lower_left )
35+ x , y = (int (v / bbox_size ) for v in box .lower_left )
4236 tiles .append (
4337 Tile (
44- id = f"{ zone } _{ row } _{ size } _{ x } _{ y } " ,
38+ id = f"{ zone } _{ row } _{ bbox_size } _{ x } _{ y } " ,
4539 epsg = box .crs .epsg ,
4640 bbox = (box .min_x , box .min_y , box .max_x , box .max_y ),
4741 ),
0 commit comments