#!/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 27.10580349 56.91830302 -gcp 21177.0 0.0 27.1026273 57.01270363 -gcp 21177.0 21186.0 27.27137044 57.01002819 -gcp 0.0 21186.0 27.27068424 56.92233184 GX825/GX_825_SK_frame_36.jpg GX_825_SK_frame_36.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "624.0 1830.0\n20448.0 1775.9465181058495\n20592.0 19007.973259052927\n672.0 19104.026740947073" | \ gdaltransform -tps -output_xy GX_825_SK_frame_36.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_825_SK_frame_36.vrt GX_825_SK_frame_36.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_825_SK_frame_36.cut.vrt GX_825_SK_frame_36.xyz