#!/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.69369173 56.37411933 -gcp 42717.0 0.0 24.64786499 56.36168488 -gcp 42717.0 43398.0 24.62232663 56.38826421 -gcp 0.0 43398.0 24.67172843 56.40196133 GX4800/GX_4800_SD_frame_120.jpg GX_4800_SD_frame_120.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "33888.0 4463.7865480822675\n2544.0 4179.0\n2112.0 38496.186770428016\n41328.0 38879.86659255142\n41376.0 5664.106725958866" | \ gdaltransform -tps -output_xy GX_4800_SD_frame_120.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_4800_SD_frame_120.vrt GX_4800_SD_frame_120.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_4800_SD_frame_120.cut.vrt GX_4800_SD_frame_120.xyz