Revision 10054
Added by Aaron Marcuse-Kubitza over 11 years ago
import | ||
---|---|---|
6 | 6 |
map_table |
7 | 7 |
psql <<'EOF' |
8 | 8 |
SELECT set_col_types('"COND"', ARRAY[ |
9 |
('STATECD', 'integer') |
|
10 |
, ('UNITCD', 'integer') |
|
11 |
, ('COUNTYCD', 'integer') |
|
9 |
('*STATECD', 'integer')
|
|
10 |
, ('*UNITCD', 'integer')
|
|
11 |
, ('*COUNTYCD', 'integer')
|
|
12 | 12 |
, ('locationName', 'integer') |
13 |
, ('INVYR', 'integer') |
|
13 |
, ('*INVYR', 'integer')
|
|
14 | 14 |
, ('authorEventCode', 'integer') |
15 | 15 |
]::col_cast[]); |
16 | 16 |
|
17 | 17 |
SELECT mk_derived_col(('"COND"', 'oldGrowth'), $$ |
18 | 18 |
( |
19 |
"COND-STDAGE"::integer>80 |
|
20 |
AND ("COND-TRTCD1"='0' OR "COND-TRTCD1" IS NULL)
|
|
21 |
AND (("COND-DSTRBCD1"<>'30' AND "COND-DSTRBCD1"<>'31' AND "COND-DSTRBCD1"<>'32' AND "COND-DSTRBCD1"<>'80') OR "COND-DSTRBCD1" IS NULL)
|
|
22 |
AND ("COND-STUMP_CD_PNWRS"='N' OR "COND-STUMP_CD_PNWRS" IS NULL)
|
|
23 |
AND "COND-HARVEST_TYPE1_SRS" IS NULL |
|
24 |
AND "COND-PRESNFCD" IS NULL |
|
25 |
AND ("COND-STDORGCD"='0' OR "COND-STDORGCD" IS NULL)
|
|
19 |
"*COND-STDAGE"::integer>80
|
|
20 |
AND ("*COND-TRTCD1"='0' OR "*COND-TRTCD1" IS NULL)
|
|
21 |
AND (("*COND-DSTRBCD1"<>'30' AND "*COND-DSTRBCD1"<>'31' AND "*COND-DSTRBCD1"<>'32' AND "*COND-DSTRBCD1"<>'80') OR "*COND-DSTRBCD1" IS NULL)
|
|
22 |
AND ("*COND-STUMP_CD_PNWRS"='N' OR "*COND-STUMP_CD_PNWRS" IS NULL)
|
|
23 |
AND "*COND-HARVEST_TYPE1_SRS" IS NULL
|
|
24 |
AND "*COND-PRESNFCD" IS NULL
|
|
25 |
AND ("*COND-STDORGCD"='0' OR "*COND-STDORGCD" IS NULL)
|
|
26 | 26 |
) |
27 |
OR "COND-STND_COND_CD_PNWRS"='7' |
|
27 |
OR "*COND-STND_COND_CD_PNWRS"='7'
|
|
28 | 28 |
$$); |
29 | 29 |
|
30 |
SELECT create_if_not_exists($$ALTER TABLE "COND" ADD CONSTRAINT "COND.ID" UNIQUE ("COND-CN")$$); |
|
31 |
SELECT create_if_not_exists($$ALTER TABLE "COND" ADD CONSTRAINT "COND.unique" UNIQUE ("STATECD", "UNITCD", "COUNTYCD", "locationName", "INVYR", "authorEventCode")$$);
|
|
30 |
SELECT create_if_not_exists($$ALTER TABLE "COND" ADD CONSTRAINT "COND.ID" UNIQUE ("*COND-CN")$$);
|
|
31 |
SELECT create_if_not_exists($$ALTER TABLE "COND" ADD CONSTRAINT "COND.unique" UNIQUE ("*STATECD", "*UNITCD", "*COUNTYCD", "locationName", "*INVYR", "authorEventCode")$$);
|
|
32 | 32 |
SELECT cluster_once('"COND"', '"COND.unique"'); |
33 | 33 |
EOF |
34 | 34 |
mk_derived |
Also available in: Unified diff
inputs/FIA/SUBPLOT/map.csv, import: prepended * to all FIA terms to clearly distinguish them from the VegCore terms. this is the standard convention for all datasources, to indicate which terms have not yet been mapped, but was not yet implemented at the beginning of new-style import (the FIA refresh was the first new-style datasource).
the following replacements were performed to make this change:
in all map.csv: replace regexp (?<=,)(?=[A-Z_]{2,}) with *
in all import:
replace regexp (?<=[^']")(?<!TABLE )(?=(?!\w+\.)[A-Z_]{2,}) with *
manually undo any replacements on table names
replace regexp (?<=\(')\b(?=(?!\w+\.)[A-Z_]{2,}) with *
$ ./inputs/FIA/import