#!/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 26.71101971 56.85757136 -gcp 21369.0 0.0 26.72874375 56.95287757 -gcp 21369.0 21510.0 26.89912872 56.93971855 -gcp 0.0 21510.0 26.8797739 56.85182438 GX825/GX_825_SK_frame_130.jpg GX_825_SK_frame_130.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "492.0 12552.0\n699.0 11766.0\n669.0 10248.0\n387.0 9402.0\n288.0 2226.0\n2166.0 2166.0\n2166.0 660.0\n20934.0 612.0\n21072.0 19692.0\n20232.0 20232.0\n19704.0 21084.0\n12012.0 21108.0\n5880.0 21264.0\n2916.0 21276.0\n2748.0 20088.0\n1764.0 19284.0\n600.0 18816.0" | \ gdaltransform -tps -output_xy GX_825_SK_frame_130.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_825_SK_frame_130.vrt GX_825_SK_frame_130.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_825_SK_frame_130.cut.vrt GX_825_SK_frame_130.xyz