#!/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 21.54869556 57.32977617 -gcp 21369.0 0.0 21.58880505 57.3124233 -gcp 21369.0 21639.0 21.55774076 57.29033774 -gcp 0.0 21639.0 21.51580095 57.30706664 GX12218/GX_12218_SD_frame_182.jpg GX_12218_SD_frame_182.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "816.0 2231.8796657381613\n20784.0 2447.9465181058495\n20736.0 20736.802228412256\n3192.0 20832.053481894152\n2280.0 19439.87966573816\n768.0 18671.786072423398" | \ gdaltransform -tps -output_xy GX_12218_SD_frame_182.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_12218_SD_frame_182.vrt GX_12218_SD_frame_182.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_12218_SD_frame_182.cut.vrt GX_12218_SD_frame_182.xyz