#!/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.50487104 56.66305256 -gcp 42468.0 0.0 25.51373598 56.74558057 -gcp 42468.0 43098.0 25.66278723 56.7419321 -gcp 0.0 43098.0 25.65823107 56.65894326 GX10504/GX_10504_SK_frame_835.jpg GX_10504_SK_frame_835.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1968.0 4415.733185102836\n1776.0 38160.08004446915\n41376.0 38112.45358532518\n41376.0 3935.599777654252" | \ gdaltransform -tps -output_xy GX_10504_SK_frame_835.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10504_SK_frame_835.vrt GX_10504_SK_frame_835.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10504_SK_frame_835.cut.vrt GX_10504_SK_frame_835.xyz