#!/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.32915115 57.30065677 -gcp 21177.0 0.0 25.2862894 57.31978457 -gcp 21177.0 20736.0 25.32049879 57.34325267 -gcp 0.0 20736.0 25.36502302 57.32371436 GX4190/GX_4190_SD_frame_76.jpg GX_4190_SD_frame_76.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "528.0 2183.919866444073\n792.0 18888.080133555926\n20952.0 18864.253756260434\n20712.0 2063.919866444073" | \ gdaltransform -tps -output_xy GX_4190_SD_frame_76.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_4190_SD_frame_76.vrt GX_4190_SD_frame_76.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_4190_SD_frame_76.cut.vrt GX_4190_SD_frame_76.xyz