Skip to content

Instantly share code, notes, and snippets.

@bitner
Created June 14, 2016 16:35
Show Gist options
  • Save bitner/a9098bebadca96bd08b63d657ca15356 to your computer and use it in GitHub Desktop.
Save bitner/a9098bebadca96bd08b63d657ca15356 to your computer and use it in GitHub Desktop.
CREATE OR REPLACE FUNCTION public.dbs_ned_z(
IN text,
IN text,
OUT text)
RETURNS text AS
$BODY$
#!/bin/sh
url="http://ned.usgs.gov/epqs/pqs.php?output=json&x=$1&y=$2"; /usr/bin/curl -s $url
$BODY$
LANGUAGE plsh VOLATILE
COST 100;
CREATE OR REPLACE FUNCTION public.dbs_point_elevation(
IN geometry,
OUT double precision)
RETURNS double precision AS
$BODY$ SELECT (dbs_ned_z(st_x($1)::text,st_y($1)::text)::json->'USGS_Elevation_Point_Query_Service'->'Elevation_Query'->>'Elevation')::float8;$BODY$
LANGUAGE sql VOLATILE
COST 100;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment