#!/bin/bash

# Script to demonstrate how to create tiled KML from an GeoTIFF

# Setup FWTools (obtained from http://fwtools.maptools.org/)
. $HOME/FWTools-2.0.6/fwtools_env.sh

# Create PROJ4 projection file from original GeoTIFF
listgeo -proj4 test.tif | grep PROJ.4 | cut -c20- > proj4.txt

# Translate to GDAL GeoTIFF
echo "(translating...)"
gdal_translate -a_srs proj4.txt -a_ullr -133.417892 52.805000 -98.235397 24.798702 test.tif test.4326.tif

# Create tiled KML from GDAL GeoTIFF
echo "(tiling...)"
gdal2tiles.py -forcekml test.4326.tif kml
