#!/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 96.0 6.0 25.89256667 56.69436667 -gcp 21792.0 102.0 25.90598333 56.61093333 -gcp 21600.0 21849.0 25.75271667 56.60171667 -gcp 0.0 21849.0 25.73508333 56.68668333 GX10511/GX_10511_SK_frame_55.jpg GX_10511_SK_frame_55.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "2544.0 4655.70388648982\n2208.0 5904.340530536705\n1008.0 5976.9179518815545\n864.0 15054.0\n21096.0 15024.01480567551\n21072.0 4464.118445404071" | \ gdaltransform -tps -output_xy GX_10511_SK_frame_55.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10511_SK_frame_55.vrt GX_10511_SK_frame_55.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10511_SK_frame_55.cut.vrt GX_10511_SK_frame_55.xyz