#!/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.89855784 57.40123519 -gcp 10200.0 0.0 25.90429041 57.31495302 -gcp 10200.0 10449.0 25.7474591 57.31020875 -gcp 0.0 10449.0 25.73462198 57.39671068 GX8473/GX_8473_SK_frame_211.jpg GX_8473_SK_frame_211.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1124.7275390625 618.5454711914062\n1100.7275390625 1380.5453796386719\n573.2728271484375 1394.1819763183594\n547.63623046875 2922.5452880859375\n285.2728271484375 3720.0003662109375\n385.63604736328125 9443.454162597656\n975.2726440429688 9447.272827148438\n1297.63623046875 9813.273193359375\n1315.6365966796875 10326.544921875\n9169.090576171875 10285.63623046875\n9183.271728515625 9769.090576171875\n9566.726806640625 9429.81884765625\n10016.181884765625 9415.090942382812\n9926.7275390625 480.0" | \ gdaltransform -tps -output_xy GX_8473_SK_frame_211.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8473_SK_frame_211.vrt GX_8473_SK_frame_211.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8473_SK_frame_211.cut.vrt GX_8473_SK_frame_211.xyz