#!/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.53393531 57.71794805 -gcp 10980.0 0.0 22.6097805 57.69858428 -gcp 10980.0 11265.0 22.58004838 57.65761615 -gcp 0.0 11265.0 22.49619126 57.67217545 GX13126/GX_13126_SG_frame_60.jpg GX_13126_SG_frame_60.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "360.0 1323.0\n10704.0 1199.9465181058495\n10632.0 9672.147075208912\n456.0 9720.120334261837" | \ gdaltransform -tps -output_xy GX_13126_SG_frame_60.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_13126_SG_frame_60.vrt GX_13126_SG_frame_60.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_13126_SG_frame_60.cut.vrt GX_13126_SG_frame_60.xyz