#!/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 27.08358407 57.42251332 -gcp 21885.0 0.0 27.07093477 57.40838047 -gcp 21885.0 20931.0 27.0453465 57.41507779 -gcp 0.0 20931.0 27.05844411 57.42927426 GX3778/GX_3778_SD_frame_180.jpg GX_3778_SD_frame_180.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "732.0 11277.0\n1041.0 11043.0\n1068.0 9606.0\n768.0 9282.0\n747.0 1471.5\n2718.0 1443.0\n2766.0 228.0\n21861.0 186.0\n21801.0 9423.0\n21585.0 9573.0\n21523.5 9928.5\n21495.0 10269.0\n21495.0 10665.0\n21576.0 11016.0\n21798.0 11160.0\n21687.0 20829.0\n12156.0 20802.0\n11967.0 20532.0\n10605.0 20535.0\n10338.0 20790.0\n2874.0 20754.0\n2910.0 19818.0\n2610.0 19062.0\n1812.0 18666.0\n738.0 18648.0" | \ gdaltransform -tps -output_xy GX_3778_SD_frame_180.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_3778_SD_frame_180.vrt GX_3778_SD_frame_180.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_3778_SD_frame_180.cut.vrt GX_3778_SD_frame_180.xyz