#!/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 23.90775204 56.85920399 -gcp 14418.0 0.0 23.87744308 56.94565869 -gcp 14418.0 14124.0 24.045116 56.97085591 -gcp 0.0 14124.0 24.07886444 56.86864323 GX2261/GX_2261_SK_frame_5.jpg GX_2261_SK_frame_5.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1632.0 411.0\n11496.0 455.7727019498609\n11592.0 13008.013370473536\n1440.0 13128.173816155988" | \ gdaltransform -tps -output_xy GX_2261_SK_frame_5.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_2261_SK_frame_5.vrt GX_2261_SK_frame_5.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_2261_SK_frame_5.cut.vrt GX_2261_SK_frame_5.xyz