#!/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 22.50542064 56.67942886 -gcp 21306.0 0.0 22.50073214 56.65476221 -gcp 21306.0 21381.0 22.45641957 56.65957077 -gcp 0.0 21381.0 22.46579389 56.68324812 GX4596/GX_4596_SD_frame_47.jpg GX_4596_SD_frame_47.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "0.0 0.0\n9627.0 0.0\n9693.0 130.5\n9781.5 211.5\n10249.5 237.0\n10669.5 199.5\n10761.0 145.5\n10824.0 0.0\n18786.0 0.0\n18714.0 945.0\n18843.0 1374.0\n19083.0 1722.0\n19506.0 1908.0\n19935.0 1953.0\n20871.0 1863.0\n20865.0 4692.0\n20902.5 9631.5\n20769.0 9805.5\n20647.5 9868.5\n20557.5 9967.5\n20559.0 10432.5\n20574.0 10885.5\n20662.5 10966.5\n20811.0 11058.0\n20913.0 11271.0\n20940.0 19323.0\n20007.0 19506.0\n18984.0 19455.0\n18840.0 19914.0\n18786.0 20991.0\n11304.0 21036.0\n10911.0 20769.0\n9807.0 20769.0\n9462.0 21072.0\n0.0 21135.0" | \ gdaltransform -tps -output_xy GX_4596_SD_frame_47.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_4596_SD_frame_47.vrt GX_4596_SD_frame_47.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_4596_SD_frame_47.cut.vrt GX_4596_SD_frame_47.xyz