#!/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 24.19987327 56.93941071 -gcp 21600.0 0.0 24.15203204 56.95601116 -gcp 21600.0 21168.0 24.18217617 56.98283886 -gcp 0.0 21168.0 24.23127641 56.96476087 GX4190/GX_4190_SD_frame_5.jpg GX_4190_SD_frame_5.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "720.0 2544.2401334074484\n672.0 18719.946637020563\n20880.0 18767.733185102836\n20736.0 2352.1867704280157" | \ gdaltransform -tps -output_xy GX_4190_SD_frame_5.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_4190_SD_frame_5.vrt GX_4190_SD_frame_5.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_4190_SD_frame_5.cut.vrt GX_4190_SD_frame_5.xyz