#!/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.0704627 57.42525722 -gcp 21306.0 0.0 27.05744863 57.41184774 -gcp 21306.0 21123.0 27.03240752 57.41886218 -gcp 0.0 21123.0 27.0459044 57.43250588 GX3778/GX_3778_SD_frame_181.jpg GX_3778_SD_frame_181.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "360.0 11652.0\n672.0 11430.0\n720.0 10692.0\n678.0 9984.0\n366.0 9702.0\n358.5 1854.0\n1389.0 1780.5\n2325.0 1857.0\n2436.0 1170.0\n2361.0 297.0\n10125.0 225.0\n10272.0 426.0\n10956.0 447.0\n11241.0 459.0\n11622.0 438.0\n11742.0 274.5\n21297.0 312.0\n21303.0 21120.0\n11680.5 21120.0\n11620.5 21031.5\n11229.0 20964.0\n10593.0 20961.0\n10213.5 21040.5\n10143.0 21120.0\n2364.0 21120.0\n2436.0 20658.0\n2469.0 20184.0\n2385.0 19800.0\n2136.0 19491.0\n1512.0 19134.0\n330.0 19167.0" | \ gdaltransform -tps -output_xy GX_3778_SD_frame_181.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_3778_SD_frame_181.vrt GX_3778_SD_frame_181.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_3778_SD_frame_181.cut.vrt GX_3778_SD_frame_181.xyz