#!/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 24.33488846 56.79153637 -gcp 10131.0 0.0 24.48631525 56.7973654 -gcp 10131.0 10470.0 24.49412584 56.71227306 -gcp 0.0 10470.0 24.3447268 56.70842793 GX10863/GX_10863_SK_frame_877.jpg GX_10863_SK_frame_877.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1140.0 564.0\n1020.0 9648.0\n9420.0 9708.0\n9264.0 672.0" | \ gdaltransform -tps -output_xy GX_10863_SK_frame_877.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10863_SK_frame_877.vrt GX_10863_SK_frame_877.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10863_SK_frame_877.cut.vrt GX_10863_SK_frame_877.xyz