#!/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.03356099 56.66362678 -gcp 14166.0 0.0 25.10572314 56.64519113 -gcp 14166.0 14244.0 25.07352591 56.60916088 -gcp 0.0 14244.0 25.00635266 56.63741555 GX4477/GX_4477L_SD_frame_99.jpg GX_4477L_SD_frame_99.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "360.0 7439.973259052925\n12144.0 7705.7114206128135\n12264.0 1774.4222841225626\n13968.0 1701.7671309192199\n14004.0 14124.0\n1632.0 14039.986629526464\n1488.0 13043.812813370474\n432.0 12696.066852367687" | \ gdaltransform -tps -output_xy GX_4477L_SD_frame_99.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_4477L_SD_frame_99.vrt GX_4477L_SD_frame_99.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_4477L_SD_frame_99.cut.vrt GX_4477L_SD_frame_99.xyz