#!/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.16226673 56.47765 -gcp 21627.0 0.0 26.1941358 56.40808678 -gcp 21627.0 21315.0 26.13642278 56.39642836 -gcp 0.0 21315.0 26.06132984 56.46195701 GX1449/GX_1449_SD_frame_183.jpg GX_1449_SD_frame_183.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "864.0 2232.0133704735376\n2592.0 2208.0\n2496.0 1079.2512534818939\n17520.0 1031.5454038997218\n17568.0 2664.467966573816\n20928.0 2639.7325905292473\n21264.0 20975.812813370474\n2880.0 20856.46796657382\n2232.0 19463.732590529245\n936.0 19200.080222841225" | \ gdaltransform -tps -output_xy GX_1449_SD_frame_183.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_1449_SD_frame_183.vrt GX_1449_SD_frame_183.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_1449_SD_frame_183.cut.vrt GX_1449_SD_frame_183.xyz