#!/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 6532.756529637187 6468.432461579466 25.86438864 56.50581566 -gcp 35017.2562109183 6574.484961700968 25.89501545 56.49533979 -gcp 35865.62210069706 31621.63646738838 25.87946534 56.47960968 -gcp 8695.505978551471 37365.53780331116 25.84351569 56.48575544 GX769/GX_769_SD_frame_109_copy.jpg GX_769_SD_frame_109_copy.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1224.0 5027.775831873905\n4176.0 4176.5323992994745\n4368.0 1080.2381786339756\n38880.0 1392.0280210157619\n38976.0 4167.285464098075\n41904.0 4166.472854640982\n41712.0 36729.471103327494\n38256.0 36825.02276707531\n38304.0 41328.532399299474\n960.0 41760.11208406305" | \ gdaltransform -tps -output_xy GX_769_SD_frame_109_copy.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_769_SD_frame_109_copy.vrt GX_769_SD_frame_109_copy.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_769_SD_frame_109_copy.cut.vrt GX_769_SD_frame_109_copy.xyz