#!/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.44341971 57.40167827 -gcp 10200.0 0.0 25.45238664 57.31313581 -gcp 10200.0 10449.0 25.29023927 57.3074201 -gcp 0.0 10449.0 25.27754277 57.39579803 GX8473/GX_8473_SK_frame_202.jpg GX_8473_SK_frame_202.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1221.2728271484375 438.54547119140625\n1232.181884765625 1169.4546203613281\n758.181884765625 1186.36376953125\n736.9090576171875 2742.0\n432.0 3398.7273559570312\n568.9090576171875 9302.726875305176\n1097.454345703125 9290.727172851562\n1458.0 9645.272827148438\n1459.0909423828125 10180.909057617188\n9379.09130859375 10050.544921875\n9357.818115234375 9604.36376953125\n9589.63623046875 9243.818115234375\n10109.454345703125 9229.09130859375\n10061.454345703125 274.9090576171875" | \ gdaltransform -tps -output_xy GX_8473_SK_frame_202.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8473_SK_frame_202.vrt GX_8473_SK_frame_202.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8473_SK_frame_202.cut.vrt GX_8473_SK_frame_202.xyz