#!/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 25.74231863 56.86069264 -gcp 13782.0 0.0 25.8875227 56.85839329 -gcp 13782.0 15018.0 25.88193297 56.77083553 -gcp 0.0 15018.0 25.73454022 56.77523866 GX10673/GX_10673_SK_frame_905.jpg GX_10673_SK_frame_905.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "780.0 1248.0\n12864.0 1224.0\n12564.0 14388.0\n1368.0 14352.0" | \ gdaltransform -tps -output_xy GX_10673_SK_frame_905.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10673_SK_frame_905.vrt GX_10673_SK_frame_905.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10673_SK_frame_905.cut.vrt GX_10673_SK_frame_905.xyz