#!/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.05379033 56.57470963 -gcp 14340.0 0.0 23.08542967 56.5858601 -gcp 14340.0 14505.0 23.10552894 56.56767826 -gcp 0.0 14505.0 23.07268381 56.55708199 GX4478/GX_4478_SD_frame_59.jpg GX_4478_SD_frame_59.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1536.0 147.0\n13968.0 167.8395543175484\n13944.0 12480.160445682452\n12936.0 12767.759331476322\n12768.0 13896.361002785514\n1536.0 14016.962674094706" | \ gdaltransform -tps -output_xy GX_4478_SD_frame_59.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_4478_SD_frame_59.vrt GX_4478_SD_frame_59.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_4478_SD_frame_59.cut.vrt GX_4478_SD_frame_59.xyz