#!/bin/bash
#
# Grab the DEM elevation for the nearest DGG polygon to a given
# location.  Could be faster if doing a lot of these, but uses
# simple shell scripting and let the OS do file caching.....

# usage: get_dem_elevation lon lat

GEOMFILE="/data/archive/DGG/500m.geom"
DEMFILE="/data/archive/DGG/500m.dem"

polyid=`/home/gettings/devel/global_grid/findpolybyloc $GEOMFILE $1 $2 | \
  awk '{print $1}'`
ele=`~/devel/global_grid/gridval2ascii $DEMFILE $polyid | head -1 | awk '{print $2}'`
echo $1 $2 $ele
