#!/bin/bash GDAL_TILE_PROCESSES=16 GDAL_TILE_ZOOMS=8-14 GDAL_SAMPLING_WARP=cubic GDAL_SAMPLING_TILE=antialias # Create virtual dataset with coordinates gdal_translate -of VRT -a_srs EPSG:4326 -outsize 300% 300% -gcp 0.0 0.0 23.13586593 56.77118819 -gcp 21048.0 0.0 23.09575886 56.75958076 -gcp 21048.0 20994.0 23.07252288 56.78220866 -gcp 0.0 20994.0 23.11480522 56.79430114 GX2685/GX_2685B_SD_frame_259.jpg GX_2685B_SD_frame_259.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "240.0 1878.0\n20832.0 1296.3208913649032\n20832.0 18959.946518105848\n336.0 18911.946518105848" | \ gdaltransform -tps -output_xy GX_2685B_SD_frame_259.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_2685B_SD_frame_259.vrt GX_2685B_SD_frame_259.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_2685B_SD_frame_259.cut.vrt GX_2685B_SD_frame_259.xyz