#!/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 2207.025395869302 6032.6516620436905 25.68284869 57.26774366 -gcp 15955.298280267103 4408.753470125796 25.68050981 57.3214645 -gcp 18086.89362605023 17916.894780379283 25.77919364 57.32424473 -gcp 2978.381695788767 16160.136478127708 25.75619102 57.26699013 GX8464/GX_8464_SK_frame_270.jpg GX_8464_SK_frame_270.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "600.0 2879.90346907994\n21168.0 2688.0241327300155\n21216.0 19726.141779788835\n720.0 19774.165912518853" | \ gdaltransform -tps -output_xy GX_8464_SK_frame_270.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8464_SK_frame_270.vrt GX_8464_SK_frame_270.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8464_SK_frame_270.cut.vrt GX_8464_SK_frame_270.xyz