#!/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.49946356 56.67164458 -gcp 21240.0 0.0 22.4713406 56.65925157 -gcp 21240.0 21573.0 22.44755745 56.67484091 -gcp 0.0 21573.0 22.47617126 56.68791076 GX4596/GX_4596_SD_frame_61.jpg GX_4596_SD_frame_61.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "480.0 1974.0\n2172.0 1872.2473537604455\n2520.0 887.7058495821727\n15888.0 839.1710306406687\n17256.0 2664.2540389972146\n20928.0 2616.093593314763\n20832.0 19175.705849582173\n744.0 19248.33426183844" | \ gdaltransform -tps -output_xy GX_4596_SD_frame_61.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_4596_SD_frame_61.vrt GX_4596_SD_frame_61.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_4596_SD_frame_61.cut.vrt GX_4596_SD_frame_61.xyz