#!/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 27.31224775 56.51833382 -gcp 21498.0 0.0 27.37139583 56.52694467 -gcp 21498.0 20931.0 27.38666515 56.49407804 -gcp 0.0 20931.0 27.32304096 56.4903395 GX769/GX_769_SD_frame_83.jpg GX_769_SD_frame_83.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "840.0 1703.9331476323118\n2400.0 1632.2674094707527\n2400.0 479.7593314763226\n20880.0 479.94651810584946\n20976.0 20184.013370473534\n2472.0 20375.986629526466\n2184.0 18911.65236768802\n696.0 18672.0" | \ gdaltransform -tps -output_xy GX_769_SD_frame_83.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_769_SD_frame_83.vrt GX_769_SD_frame_83.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_769_SD_frame_83.cut.vrt GX_769_SD_frame_83.xyz