#!/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.45213633 56.66911498 -gcp 21600.0 0.0 22.44403303 56.69157557 -gcp 21600.0 21789.0 22.48568237 56.6958792 -gcp 0.0 21789.0 22.49331057 56.67334815 GX4471/GX_4471_SD_frame_82.jpg GX_4471_SD_frame_82.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "900.0 2382.0\n1032.0 19464.0\n21360.0 19632.0\n21420.0 2532.0" | \ gdaltransform -tps -output_xy GX_4471_SD_frame_82.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_4471_SD_frame_82.vrt GX_4471_SD_frame_82.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_4471_SD_frame_82.cut.vrt GX_4471_SD_frame_82.xyz