#!/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 21.01239324 56.49215787 -gcp 21435.0 0.0 21.06320139 56.49609692 -gcp 21435.0 21444.0 21.06942281 56.46837409 -gcp 0.0 21444.0 21.01789713 56.46411458 GX12218/GX_12218_SD_frame_192.jpg GX_12218_SD_frame_192.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "768.0 2351.9465181058495\n20736.0 2063.919777158774\n21048.0 20616.28077994429\n2976.0 20736.1069637883\n2496.0 19319.732590529245\n816.0 18743.933147632313" | \ gdaltransform -tps -output_xy GX_12218_SD_frame_192.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_12218_SD_frame_192.vrt GX_12218_SD_frame_192.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_12218_SD_frame_192.cut.vrt GX_12218_SD_frame_192.xyz