swectral.croproi#
- swectral.croproi(raster_path, roi_coordinates, output_path, *, _space_wait_timeout=6, _reserve_free_pct=5.0)[source]#
Crop a region of interest (ROI) from a raster image and save croped region to a new image.
- Parameters:
- raster_path
str Source raster path.
- roi_coordinates
listoflistoftupleof2 (floatorint) Coordinates of the ROI polygons. Structure:
[ [ (x1, y1), (x2, y2), ..., (xn, yn), (x1, y1) ], # Polygon 1 [ (x1, y1), (x2, y2), ..., (xm, ym), (x1, y1) ], # Polygon 2 ... ]
Each inner list represents a polygon (for multipart geometries), and each tuple is a vertex coordinate.
- output_path
str Output raster path.
- raster_path
- Return type:
Examples
>>> croproi("/image1.tif", [[(0, 0), (0, 10), (10, 0), (0, 0)]], output_path="/image1_cropped.tif")