#!/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.47113132 56.93930903 -gcp 21435.0 0.0 23.57841969 56.94476351 -gcp 21435.0 21573.0 23.58481407 56.88997771 -gcp 0.0 21573.0 23.49029303 56.88295018 GX4161/GX_4161_SK_frame_27.jpg GX_4161_SK_frame_27.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "756.0 2183.846239554318\n2424.0 2112.213927576602\n2448.0 1008.0\n18048.0 648.0\n18072.0 2592.467966573816\n21168.0 2687.919777158774\n21240.0 21288.026740947076\n2832.0 21096.33426183844\n2520.0 19631.65236768802\n816.0 19200.053481894152" | \ gdaltransform -tps -output_xy GX_4161_SK_frame_27.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_4161_SK_frame_27.vrt GX_4161_SK_frame_27.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_4161_SK_frame_27.cut.vrt GX_4161_SK_frame_27.xyz