#!/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 22.82528954 56.67455742 -gcp 20934.0 0.0 22.75083066 56.68856269 -gcp 20934.0 21072.0 22.77776888 56.72533572 -gcp 0.0 21072.0 22.8465047 56.70031329 GX2685/GX_2685B_SD_frame_291.jpg GX_2685B_SD_frame_291.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1128.0 1803.0\n936.0 18852.0\n20496.0 18935.985688729874\n20544.0 1584.1001788908768" | \ gdaltransform -tps -output_xy GX_2685B_SD_frame_291.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_2685B_SD_frame_291.vrt GX_2685B_SD_frame_291.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_2685B_SD_frame_291.cut.vrt GX_2685B_SD_frame_291.xyz