#!/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 27.60357857 56.50805743 -gcp 14376.0 0.0 27.67811179 56.43981697 -gcp 14376.0 14340.0 27.54491329 56.39692326 -gcp 0.0 14340.0 27.47899532 56.47216293 GX1643/GX_1643_SK_frame_1.jpg GX_1643_SK_frame_1.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "792.0 1269.192200557103\n1848.0 1284.2607242339832\n1884.0 360.20055710306383\n14208.0 647.9598885793871\n14112.0 14064.04011142061\n2940.0 13968.040111420614\n2928.0 12311.552089136489\n528.0 12262.83676880223" | \ gdaltransform -tps -output_xy GX_1643_SK_frame_1.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_1643_SK_frame_1.vrt GX_1643_SK_frame_1.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_1643_SK_frame_1.cut.vrt GX_1643_SK_frame_1.xyz