#!/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.80471569 56.50160833 -gcp 21477.0 0.0 25.85344499 56.49635323 -gcp 21477.0 21171.0 25.84573182 56.46894461 -gcp 0.0 21171.0 25.79419433 56.4760937 GX1443/GX_1443_SD_frame_7.jpg GX_1443_SD_frame_7.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "768.0 3024.0\n714.0 19434.0\n21168.0 19680.0\n21066.0 2994.0" | \ gdaltransform -tps -output_xy GX_1443_SD_frame_7.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_1443_SD_frame_7.vrt GX_1443_SD_frame_7.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_1443_SD_frame_7.cut.vrt GX_1443_SD_frame_7.xyz