#!/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 23.82759647 55.04158607 -gcp 21600.0 0.0 23.78523238 55.05101963 -gcp 21600.0 20982.0 23.79969043 55.0750733 -gcp 0.0 20982.0 23.84496789 55.06630413 GX2685/GX_2685B_SD_frame_100.jpg GX_2685B_SD_frame_100.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "648.0 1728.0\n792.0 19008.0\n20928.0 18912.0\n20832.0 1536.0" | \ gdaltransform -tps -output_xy GX_2685B_SD_frame_100.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_2685B_SD_frame_100.vrt GX_2685B_SD_frame_100.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_2685B_SD_frame_100.cut.vrt GX_2685B_SD_frame_100.xyz