Skip to content

Commit f3f1a38

Browse files
committed
get_vegplot_from_NASIS_db: remove peiid and pedon join in base query; merge in from "site" query
- prevents unintended duplication with multiple pedon per site
1 parent 4631401 commit f3f1a38

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

R/fetchVegdata.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fetchVegdata <- function(SS=TRUE, stringsAsFactors = NULL, dsn = NULL) {
5151
}
5252

5353
# add ecosite id, corrdate, selection method to vegplot
54-
vegplot <- merge(site[,c("siteiid", "ecositeid", "ecositecorrdate", "siteecositehistory.classifier", "es_selection_method")],
54+
vegplot <- merge(site[,c("siteiid", "ecositeid", "peiid", "ecositecorrdate", "siteecositehistory.classifier", "es_selection_method")],
5555
vegplot, by = "siteiid", all.x = TRUE, sort = FALSE)
5656

5757
# done

R/get_vegplot_data_from_NASIS_db.R

+30-2
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,40 @@ get_vegplot_from_NASIS_db <- function(SS = TRUE,
1111
NASISDomainsAsFactor(stringsAsFactors)
1212
}
1313

14-
q.vegplot <- "SELECT siteiid, so.siteobsiid, p.peiid, usiteid as site_id, assocuserpedonid as pedon_id, v.vegplotid as vegplot_id, vegplotiid, vegplotname, obsdate, primarydatacollector, datacollectionpurpose, vegdataorigin, vegplotsize, soilprofileindicator, soil232idlegacy, ahorizondepth, alkalinesalineindicator, alkalineaffected, salinityclass, restrictivelayerdepthlegacy, legacysoilcompname, legacysoilphase, legacylocalsoilphase, legacysoilsurftext, legacysurftextmod, legacyterminlieu, erosionclasslegacy, landformgrouplegacy, cryptogamcovcllegacy, rangelandusehistory, cancovpctplotave, cancovtotalpct, cancovtotalclass, overstorycancontotalpct, overstorycancovtotalclass, dblsampannualprodave, compyieldproductionave, abovegroundbiomasstotave, understoryreprodabundance, woodyunderstoryabundance, herbundertoryabundance, lichensunderstoryabundance, crowncanclosurepct, crowncancloseassessmethod, crowncompfactorlpp, crowncomplppavedbh, basalcoverpctave, basalareaplottotal, basalareaassessmethod, constreeshrubgrp, windbreakrowonedirection, windbreaktrappedsoildepth, windbreaktrappedsoiltexture, understorydescindicator, mensurationdataindicator, vigorclasslegacy, siteconditionlegacy, overstoryspecieslegacy, plantmoiststate, currenttreedensity, currenttreespacing, currentdxspacing, currentplotavedbh, plotbasalareafactor, currentbasalarea, foreststandtype, foreststratainventoried, foreststandregen, foreststandquality, desiredtreedensity, desireddxspacing, desiredbasalarea, excessbasalarea, excesstreedensity, stockingchangepct, treepctgoodcondition, treepctfaircondition, treepctpoorcondition, treecounttotal, treesnagdensityhard, treesnagdensitysoft, pastureforagetype, pasturestanddensityave, pastureplanthtave, pastureprodave, pcidesirableplants, pciplantcover, pciplantdiversity, pcigroundcovresidue, pcistandingdeadforage, pciplantresiduecompscore, pciplantvigor, pcilegumepctclass, pciuseuniformity, pcilivestockconcareas, pcisoilcompaction, pcisheetrillerosion, pciwinderosion, pcistreamshoreerosion, pcigullyerosion, pcierosioncompscore, pcipastureconditionscore, refplantcommunity, repannualprod, totestannualprod, totallowableannualprod, totpalatableannualprod, similarityindex, annualuseableprod, harvesteffpct, takehalfleavehalf, acresperaum, aumperacre, audperacre, desirableplantvigor, desirableseedlingabundance, decadentplantabundance, plantresidueadequacy, undesirableinvadingspecies, majorinvadingspecies, invadingspeciescancovpct, soilsurferosion, soilcrusting, soilcompaction, baregroundpct, gullyrillpresence, soildegradationrating, rangetrendcurrent, rangetrendplanned, qcreviewperson, qcreviewdate, qareviewperson, qareviewdate, swcdlegacy, fieldofficelegacy, nrcsarealegacy, aktotallichencoverpct, aktotallitter1coverpct, aktotallitter2coverpct, aktotalmosscoverpct, aktotalrockcoverpct, aktotalsoilcoverpct, aktotalwatercoverpct, akecologicalsitestatus, aktotalbedrockcoverpct, akfieldecositeid
14+
q.vegplot <- "SELECT siteiid, so.siteobsiid, usiteid as site_id, assocuserpedonid as pedon_id,
15+
v.vegplotid as vegplot_id, vegplotiid, vegplotname, obsdate, primarydatacollector, datacollectionpurpose,
16+
vegdataorigin, vegplotsize, soilprofileindicator, soil232idlegacy, ahorizondepth, alkalinesalineindicator,
17+
alkalineaffected, salinityclass, restrictivelayerdepthlegacy, legacysoilcompname, legacysoilphase,
18+
legacylocalsoilphase, legacysoilsurftext, legacysurftextmod, legacyterminlieu, erosionclasslegacy,
19+
landformgrouplegacy, cryptogamcovcllegacy, rangelandusehistory, cancovpctplotave, cancovtotalpct,
20+
cancovtotalclass, overstorycancontotalpct, overstorycancovtotalclass, dblsampannualprodave,
21+
compyieldproductionave, abovegroundbiomasstotave, understoryreprodabundance, woodyunderstoryabundance,
22+
herbundertoryabundance, lichensunderstoryabundance, crowncanclosurepct, crowncancloseassessmethod,
23+
crowncompfactorlpp, crowncomplppavedbh, basalcoverpctave, basalareaplottotal, basalareaassessmethod,
24+
constreeshrubgrp, windbreakrowonedirection, windbreaktrappedsoildepth, windbreaktrappedsoiltexture,
25+
understorydescindicator, mensurationdataindicator, vigorclasslegacy, siteconditionlegacy,
26+
overstoryspecieslegacy, plantmoiststate, currenttreedensity, currenttreespacing, currentdxspacing,
27+
currentplotavedbh, plotbasalareafactor, currentbasalarea, foreststandtype, foreststratainventoried,
28+
foreststandregen, foreststandquality, desiredtreedensity, desireddxspacing, desiredbasalarea,
29+
excessbasalarea, excesstreedensity, stockingchangepct, treepctgoodcondition, treepctfaircondition,
30+
treepctpoorcondition, treecounttotal, treesnagdensityhard, treesnagdensitysoft, pastureforagetype,
31+
pasturestanddensityave, pastureplanthtave, pastureprodave, pcidesirableplants, pciplantcover,
32+
pciplantdiversity, pcigroundcovresidue, pcistandingdeadforage, pciplantresiduecompscore, pciplantvigor,
33+
pcilegumepctclass, pciuseuniformity, pcilivestockconcareas, pcisoilcompaction, pcisheetrillerosion,
34+
pciwinderosion, pcistreamshoreerosion, pcigullyerosion, pcierosioncompscore, pcipastureconditionscore,
35+
refplantcommunity, repannualprod, totestannualprod, totallowableannualprod, totpalatableannualprod,
36+
similarityindex, annualuseableprod, harvesteffpct, takehalfleavehalf, acresperaum, aumperacre,
37+
audperacre, desirableplantvigor, desirableseedlingabundance, decadentplantabundance,
38+
plantresidueadequacy, undesirableinvadingspecies, majorinvadingspecies, invadingspeciescancovpct,
39+
soilsurferosion, soilcrusting, soilcompaction, baregroundpct, gullyrillpresence, soildegradationrating,
40+
rangetrendcurrent, rangetrendplanned, qcreviewperson, qcreviewdate, qareviewperson,
41+
qareviewdate, swcdlegacy, fieldofficelegacy, nrcsarealegacy, aktotallichencoverpct,
42+
aktotallitter1coverpct, aktotallitter2coverpct, aktotalmosscoverpct, aktotalrockcoverpct,
43+
aktotalsoilcoverpct, aktotalwatercoverpct, akecologicalsitestatus, aktotalbedrockcoverpct, akfieldecositeid
1544
FROM
1645
site_View_1 AS s
1746
INNER JOIN siteobs_View_1 AS so ON so.siteiidref=s.siteiid
1847
INNER JOIN vegplot_View_1 AS v ON v.siteobsiidref=so.siteobsiid
19-
LEFT OUTER JOIN pedon_View_1 AS p ON p.siteobsiidref=so.siteobsiid
2048
ORDER BY s.siteiid;"
2149

2250
channel <- dbConnectNASIS(dsn)

0 commit comments

Comments
 (0)