#!/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.24322128 56.77257567 -gcp 22335.0 0.0 24.24613992 56.85912048 -gcp 22335.0 21315.0 24.40172906 56.85949581 -gcp 0.0 21315.0 24.39900398 56.77031806 GX10673/GX_10673_SK_frame_1.jpg GX_10673_SK_frame_1.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "672.0 1824.0\n20472.0 1560.0\n21048.0 19128.0\n576.0 18912.0" | \ gdaltransform -tps -output_xy GX_10673_SK_frame_1.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10673_SK_frame_1.vrt GX_10673_SK_frame_1.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10673_SK_frame_1.cut.vrt GX_10673_SK_frame_1.xyz