cars.extractroi
cars-extractroi: helper to extract region of interest from image product
Functions
|
Get image bounds in the dataset local pixel coordinate system. |
|
Get image bounds in the dataset pixel coordinate system. |
|
Get requested bounds in the dataset pixel coordinate system. |
|
Checks if the bounding box is within the image. |
|
get slices from bounding box |
|
Processes an image file by extracting a region based on the given geometry. |
|
Get the human-readable bounding box from an image dataset. |
|
Validate the bounding box coordinates. |
|
Create and save a .RPB file from a rasterio dataset |
|
Main cars-extractroi entrypoint |
Module Contents
- cars.extractroi.get_local_image_box(image_dataset)[source]
Get image bounds in the dataset local pixel coordinate system.
- Parameters:
image_dataset (rio.DatasetReader): Opened image dataset.
- Returns:
shapely.geometry.Polygon: Image bounds in local pixel coordinates.
- cars.extractroi.get_transformed_image_box(image_dataset)[source]
Get image bounds in the dataset pixel coordinate system.
- Parameters:
image_dataset (rio.DatasetReader): Opened image dataset.
- Returns:
shapely.geometry.Polygon: Image bounds expressed in the same pixel coordinate system as the affine transform and RPC row/col results.
- cars.extractroi.get_requested_box(bbx, transformer)[source]
Get requested bounds in the dataset pixel coordinate system.
- Parameters:
bbx (array): The bounding box in geographic coordinates. transformer (rio.transform.RPCTransformer): RPC transformer.
- Returns:
tuple: Requested box as a shapely polygon and the list of projected corner coordinates as (row, col) tuples.
- cars.extractroi.is_bbx_in_image(bbx, image_dataset)[source]
Checks if the bounding box is within the image.
- Parameters:
bbx (array): The bounding box of the image in pixel coordinates. image_dataset (rio.DatasetReader): Opened image dataset.
- cars.extractroi.get_slices_from_bbx(image_dataset, bbx, rpc_options, external_rpc=None)[source]
get slices from bounding box
- Parameters:
image_dataset (rio.DatasetReader): Opened image dataset. bbx (array): The bounding box of the image. rpc_options (dict): Options for GDALCreateRPCTransformer.
- Returns:
tuple: The slices from the bounding box.
- cars.extractroi.process_image_file(bbx, input_image_path, output_image_path, rpb_file_path, rpc_options, external_rpc_file=None)[source]
Processes an image file by extracting a region based on the given geometry.
- Parameters:
region_geometry (dict): GeoJSON-like dictionary defining the region. input_image_path (str): Path to the input image file. output_image_path (str): Path to save the output image. rpb_file_path (str): Path to save the .RPB file. rpc_options (dict): Options for GDALCreateRPCTransformer.
- cars.extractroi.get_human_readable_bbox(image_dataset, rpc_options, external_rpc=None, use_local_coordinates=True)[source]
Get the human-readable bounding box from an image dataset.
- Parameters:
image_dataset (rio.DatasetReader): Opened image dataset. rpc_options (dict): Options for GDALCreateRPCTransformer.
- Returns:
tuple: The human-readable bounding box in the format (min_x, max_x, min_y, max_y).
- cars.extractroi.validate_bounding_box(bbx, image_dataset, rpc_options, external_rpc=None)[source]
Validate the bounding box coordinates.
- Parameters:
bbx (array): The bounding box of the image. image_dataset (rio.DatasetReader): Opened image dataset. rpc_options (dict): Options for GDALCreateRPCTransformer.