#!/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.60415816 56.87855722 -gcp 14160.0 0.0 23.70967627 56.88235867 -gcp 14160.0 14082.0 23.70924711 56.82651812 -gcp 0.0 14082.0 23.61393213 56.82466841 GX4161/GX_4161_SK_frame_88.jpg GX_4161_SK_frame_88.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "384.0 1203.0\n1440.0 1296.2807799442896\n1656.0 359.465181058496\n11832.0 335.6924791086351\n11904.0 1560.3877437325907\n13968.0 1608.2406685236774\n13896.0 13656.548189415042\n1656.0 13728.601671309192\n1488.0 12815.772701949862\n240.0 12479.933147632313" | \ gdaltransform -tps -output_xy GX_4161_SK_frame_88.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_4161_SK_frame_88.vrt GX_4161_SK_frame_88.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_4161_SK_frame_88.cut.vrt GX_4161_SK_frame_88.xyz