#!/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.30642303 57.06658085 -gcp 42708.0 0.0 26.31329077 56.98355844 -gcp 42708.0 42837.0 26.15942591 56.97841441 -gcp 0.0 42837.0 26.14806338 57.06257341 GX220/GX_220_SK_frame_592.jpg GX_220_SK_frame_592.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "2976.0 3936.0\n2544.0 37536.0\n38832.0 37872.0\n39648.0 3264.0" | \ gdaltransform -tps -output_xy GX_220_SK_frame_592.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_220_SK_frame_592.vrt GX_220_SK_frame_592.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_220_SK_frame_592.cut.vrt GX_220_SK_frame_592.xyz