#!/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.7484529 56.71381604 -gcp 14247.0 0.0 24.71919537 56.79947912 -gcp 14247.0 13911.0 24.87929106 56.82353523 -gcp 0.0 13911.0 24.91643429 56.72488431 GX2261/GX_2261_SK_frame_95.jpg GX_2261_SK_frame_95.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1608.0 792.0267409470753\n11232.0 503.90640668523656\n11400.0 12815.839554317548\n1440.0 12887.94651810585" | \ gdaltransform -tps -output_xy GX_2261_SK_frame_95.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_2261_SK_frame_95.vrt GX_2261_SK_frame_95.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_2261_SK_frame_95.cut.vrt GX_2261_SK_frame_95.xyz