#!/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 26.801085 56.0238744 -gcp 45132.0 0.0 26.76692467 56.04465631 -gcp 45132.0 43896.0 26.80444848 56.06572466 -gcp 0.0 43896.0 26.84070502 56.0422838 GX737/GX_737_SD_frame_106.jpg GX_737_SD_frame_106.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "35904.0 6131.886603668705\n33360.0 4991.573096164536\n3072.0 5328.106725958865\n3168.0 39456.213451917734\n42912.0 39264.13340744858\n42960.0 6143.946637020567" | \ gdaltransform -tps -output_xy GX_737_SD_frame_106.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_737_SD_frame_106.vrt GX_737_SD_frame_106.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_737_SD_frame_106.cut.vrt GX_737_SD_frame_106.xyz