#!/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 25.87109685 56.86160132 -gcp 14427.0 0.0 26.02273822 56.85630518 -gcp 14427.0 15315.0 26.0105288 56.76825511 -gcp 0.0 15315.0 25.85806131 56.77619092 GX10673/GX_10673_SK_frame_903.jpg GX_10673_SK_frame_903.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "912.0 1260.0\n12744.0 1236.0\n12804.0 14580.0\n1380.0 14496.0" | \ gdaltransform -tps -output_xy GX_10673_SK_frame_903.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10673_SK_frame_903.vrt GX_10673_SK_frame_903.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10673_SK_frame_903.cut.vrt GX_10673_SK_frame_903.xyz