#!/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.7671988 56.54397713 -gcp 21477.0 0.0 25.80658436 56.55747814 -gcp 21477.0 21171.0 25.83387852 56.53509209 -gcp 0.0 21171.0 25.79047974 56.52123826 GX1443/GX_1443_SD_frame_4.jpg GX_1443_SD_frame_4.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "624.0 2976.0\n816.0 19128.0\n21096.0 19416.0\n20976.0 2784.0" | \ gdaltransform -tps -output_xy GX_1443_SD_frame_4.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_1443_SD_frame_4.vrt GX_1443_SD_frame_4.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_1443_SD_frame_4.cut.vrt GX_1443_SD_frame_4.xyz