#!/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 25.77086806 56.51288223 -gcp 21477.0 0.0 25.81534982 56.52057105 -gcp 21477.0 21171.0 25.83135724 56.4952554 -gcp 0.0 21171.0 25.78333497 56.48696908 GX1443/GX_1443_SD_frame_6.jpg GX_1443_SD_frame_6.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "672.0 2640.0\n480.0 18888.0\n21096.0 19248.0\n21000.0 2832.0" | \ gdaltransform -tps -output_xy GX_1443_SD_frame_6.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_1443_SD_frame_6.vrt GX_1443_SD_frame_6.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_1443_SD_frame_6.cut.vrt GX_1443_SD_frame_6.xyz