#!/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.9521337 57.4012584 -gcp 10200.0 0.0 25.9647001 57.31525148 -gcp 10200.0 10449.0 25.80799561 57.30651235 -gcp 0.0 10449.0 25.79076593 57.39278029 GX8473/GX_8473_SK_frame_212.jpg GX_8473_SK_frame_212.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1014.545654296875 752.7273559570312\n1020.5454711914062 1402.36376953125\n514.3635864257812 1449.2726440429688\n466.9090576171875 2974.3635864257812\n165.8184814453125 3581.4547119140625\n378.00018310546875 9543.817840576172\n796.9090576171875 9548.181884765625\n1111.6364135742188 9699.2724609375\n1220.181884765625 9980.181884765625\n1203.818115234375 10391.454345703125\n9087.817932128906 10375.090942382812\n9096.0 9800.727172851562\n9305.454345703125 9529.63623046875\n9913.63623046875 9487.090576171875\n9757.63623046875 555.8182983398438" | \ gdaltransform -tps -output_xy GX_8473_SK_frame_212.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8473_SK_frame_212.vrt GX_8473_SK_frame_212.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8473_SK_frame_212.cut.vrt GX_8473_SK_frame_212.xyz