#!/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.18352056 56.36541653 -gcp 21885.0 0.0 26.14072809 56.35139334 -gcp 21885.0 21315.0 26.11314814 56.3753698 -gcp 0.0 21315.0 26.15894079 56.39037933 GX704/GX_704_SD_frame_45.jpg GX_704_SD_frame_45.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "2112.0 19439.772701949863\n624.0 18940.57270194986\n816.0 1907.9532033426183\n2196.0 1920.3275766016714\n2232.0 672.0\n18648.0 648.0133704735376\n18624.0 1986.9994428969358\n21192.0 2178.7988857938726\n20976.0 20903.906406685237\n2304.0 20784.1069637883" | \ gdaltransform -tps -output_xy GX_704_SD_frame_45.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_704_SD_frame_45.vrt GX_704_SD_frame_45.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_704_SD_frame_45.cut.vrt GX_704_SD_frame_45.xyz