#!/bin/bash

vrt=vrt.vrt
shp=extent.shp
tif=${vrt%vrt}tif


gdalbuildvrt -tr 20 20 -tap -srcnodata 0 -vrtnodata 0 -r nearest $vrt *.tif 
gdal_translate $vrt $tif
gdal_trace_outline $tif -dp-toler 2 -ndv 0 -erosion -out-cs en -ogr-out $shp 
ogr2ogr -t_srs EPSG:4269 NAD83_$shp $shp
rm -f $vrt $shp extent.dbf extent.prj extent.shx $tif