#!/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 24.17373495 56.91711506 -gcp 21600.0 0.0 24.117874 56.92360495 -gcp 21600.0 21168.0 24.12963653 56.95511822 -gcp 0.0 21168.0 24.18722163 56.9466798 GX4190/GX_4190_SD_frame_2.jpg GX_4190_SD_frame_2.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1104.0 2183.746525847693\n1140.0 7140.240133407448\n1926.0 11220.406892718176\n1248.0 14063.479710950527\n1200.0 18143.639799888828\n2952.0 20400.37354085603\n20976.0 20664.03335186215\n20952.0 7620.060033351861\n19896.0 5973.425236242357\n19944.0 2304.0800444691495" | \ gdaltransform -tps -output_xy GX_4190_SD_frame_2.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_4190_SD_frame_2.vrt GX_4190_SD_frame_2.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_4190_SD_frame_2.cut.vrt GX_4190_SD_frame_2.xyz