-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplot_sql.sql
More file actions
43 lines (43 loc) · 1.27 KB
/
plot_sql.sql
File metadata and controls
43 lines (43 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
SELECT (
SELECT(
CASE
WHEN (yearAbove - yearBelow) = 0 THEN belowVal
ELSE belowVal + ((aboveVal - belowVal)/ NULLIF((yearAbove - yearBelow), 0))*(yearBP - yearBelow)
END ) as value
FROM (
SELECT
ST_Value(rast, bandBelow, pt) as belowVal,
ST_Value(rast, bandAbove, pt) as aboveVal,
yearBelow, yearAbove,
yearBP,
id
FROM
data_d7c09599b8d211e6bef09cf387ae7186
WHERE ST_Intersects(rast, pt)) as xvals
) as x,
(
SELECT(
CASE
WHEN (yearAbove - yearBelow) = 0 THEN belowVal
ELSE belowVal + ((aboveVal - belowVal)/ NULLIF((yearAbove - yearBelow), 0))*(yearBP - yearBelow)
END ) as value
FROM (
SELECT
ST_Value(rast, bandBelow, pt) as belowVal,
ST_Value(rast, bandAbove, pt) as aboveVal,
yearBelow, yearAbove,
yearBP,
id
FROM
data_d7c09599b8d211e6bef09cf387ae7186
WHERE ST_Intersects(rast, pt)) as yvals
) as y
FROM
(select p.geom as pt,
p.yearBelow as yearBelow,
p.yearAbove as yearAbove,
p.bandBelow as bandBelow,
p.bandAbove as bandAbove,
p.yr as yearBP,
p.id as id
from pointrequests as p WHERE callID = 'e87c0e60-b1b5-11e6-832e-db058c7a17cd') as makePoint ;