slice satelitte images for analysis
python slice_image.py --image_path "./images" --image_file_name "my_satellite_image.tif" --output_path "./tiles" --tile_size 512 512 --overlap 0.2
--image_file_name: The name of the image file to be sliced. (Default: 'satellite_image.tif').
--output_path: The directory where the tiles will be saved. (Default: ./output_tiles).
--tile_size: The size of each tile in pixels. This should be provided as two integers (e.g., 256 256)(Default: 256x256).
--overlap: The overlap between tiles as a percentage. (Default: 0.1, or 10%).
The script uses rasterio to open geospatial satellite images and handles georeferencing information.
The tile_size parameter defines the size of the sliced tiles (default is 256x256 pixels). The overlap parameter specifies the percentage overlap between tiles (default is 10%).
Each tile is named with a convention that includes the UTM zone, coordinates of the upper-left corner of the tile, the date and time of image acquisition, and the tile size.
The tiles are saved in the specified output_dir in PNG format, with the georeferenced data stored in the filename.
tile_UTM32_563400E_5432000N_20230924T103000_256x256.png
The script extracts metadata such as image acquisition date and time, and automatically generates filenames based on geographic location and timestamp. The rasterio library handles the geospatial aspects, including CRS and transformation, ensuring that each tile can be correctly referenced geographically. This script can be easily adapted for other use cases, including different tile sizes or formats like GeoTIFF.
resolution of the satelittes images: On Copernicus, image download must be: Image width and height must be between 1px and 2500px