#!/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.12475004 56.66381797 -gcp 21540.0 0.0 26.13716054 56.74811242 -gcp 21540.0 23217.0 26.29699425 56.74247707 -gcp 0.0 23217.0 26.2914501 56.65875902 GX10504/GX_10504_SK_frame_825.jpg GX_10504_SK_frame_825.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "600.0 2448.0\n492.0 19554.0\n20676.0 19884.0\n20760.0 2040.0" | \ gdaltransform -tps -output_xy GX_10504_SK_frame_825.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10504_SK_frame_825.vrt GX_10504_SK_frame_825.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10504_SK_frame_825.cut.vrt GX_10504_SK_frame_825.xyz