-
Notifications
You must be signed in to change notification settings - Fork 3
/
test_nlcd_figures.R
155 lines (111 loc) · 4.43 KB
/
test_nlcd_figures.R
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
setWindowTitle(paste('NPScape Database PDD Figures',R.version$arch))
# setwd('f:/NPScape/AutoFigures')
pkgList <- c("RODBC","grid","gridExtra","ggplot2",'beepr','devtools')
inst <- pkgList %in% installed.packages()
if (length(pkgList[!inst]) > 0) install.packages(pkgList[!inst])
lapply(pkgList, library, character.only = TRUE)
GitDir <- 'f:/Git/NPScapeVisualization'
source(paste(GitDir,'fetch_nlcd.R',sep='/'))
source(paste(GitDir,'AutoFigure_nlcd.R',sep='/'))
NPScapeConnectString <- paste("Driver=SQL Server; ",
"Server=INP2300FCSWUPA5\\GISDATA; ",
"uid=NPScape_Viewer;pwd=viewer2013…;",
sep='')
#INP2300FCSWUPA5\GISDATA
odbcNPScape <- odbcDriverConnect(NPScapeConnectString)
TableList <- sqlTables(odbcNPScape)[2:4]
TableList <- TableList$TABLE_NAME[TableList$TABLE_SCHEM=='dbo']
# n.b. as of July 2014, the only views (stored queries) are system views
# If user stored queries are developed, they should still have 'db' as TABLE_SCHEM
##############################################################################
# Grab Utility Tables
luUnits <- sqlFetch(odbcNPScape,'tlu_NPS_Units',
as.is=TRUE,stringsAsFactors=FALSE)
str(luUnits)
#luNPScapeUnits <- sqlFetch(odbcNPScape,'tlu_NPScape_Units',
# as.is=TRUE,stringsAsFactors=FALSE)
#str(luNPScapeUnits)
#luIMunits <- sqlFetch(odbcNPScape,"tlu_IM_Units",
# as.is=TRUE,stringsAsFactors=FALSE)
#str(IMunits) # lookup table of codes & names
#xParkNetwork <- sqlFetch(odbcNPScape,'xref_Parks_Networks',
# as.is=TRUE,stringsAsFactors=FALSE)
#str(xParkNetwork)
#xParkRegion <- sqlFetch(odbcNPScape,'xref_Parks_NPS_Regions',
# as.is=TRUE,stringsAsFactors=FALSE)
#str(xParkRegion)
xNPS_FWS_LCC <- sqlFetch(odbcNPScape,'xref_NPS_FWS_LCC',
as.is=TRUE,stringsAsFactors=FALSE)
str(xNPS_FWS_LCC)
xPNR <- sqlFetch(odbcNPScape,'tlu_IMParksNetworksRegions',
as.is=TRUE,stringsAsFactors=FALSE)
str(xPNR)
AOAlist <- c('Park','3km','30km')
##############################################################################
# source('fetch_hdd.R')
# source('fetch_nlcd.R')
# source('fetch_pdd.R')
# source('AutoFigure_hdd.R')
TestUnits <- c('GOGA','SAMO','CABR','SAGU','PETR','AUTO','TIMU',
'CACL','GOIS','RORI','JEFF','KEMO','BOHA','MISS','BISC')
TestUnits <- c('GOGA','SAMO','CABR','SAGU','PETR','TIMU',
'KEMO','BOHA','MISS','BISC')
NCPNunits <- xPNR$UnitCode[xPNR$NetworkCode=='NCPN']
L1 <- AutoFigure_nlcd('COLM',
Metric='lac1',
AOA=c('Park','3km','30km'),
Year=2011,
dsn=NULL,
Display=TRUE,
Files=NULL)
L2 <- AutoFigure_nlcd('COLM',
Metric='lac2',
AOA=c('Park','3km','30km'),
Year=2011,
dsn=NULL,
Display=TRUE,
Files=NULL)
Lnc <- AutoFigure_nlcd('COLM',
Metric='lnc',
AOA=c('Park','3km','30km'),
Year=2011,
dsn=NULL,
Display=TRUE,
Files=NULL)
# multiple units
L1u <- AutoFigure_nlcd(NCPNunits,
Metric='lac1',
AOA=c('Park','3km','30km'),
Year=2011,
dsn=NULL,
Display=TRUE,
Files=NULL)
L2u <- AutoFigure_nlcd(NCPNunits,
Metric='lac2',
AOA=c('Park','3km','30km'),
Year=2011,
dsn=NULL,
Display=TRUE,
Files=NULL)
Lncu <- AutoFigure_nlcd(NCPNunits,
Metric='lnc',
AOA=c('Park','3km','30km'),
Year=2011,
dsn=NULL,
Display=TRUE,
Files=NULL)
# Multiple Years
L1y <- AutoFigure_nlcd('COLM',
Metric='lac1',
AOA=c('Park','3km','30km'),
Year=c(2001,2006,2011),
dsn=NULL,
Display=TRUE,
Files=NULL)
L1uy <- AutoFigure_nlcd(NCPNunits[1:3],
Metric='lac1',
AOA=c('Park','3km','30km'),
Year=c(2001,2006,2011),
dsn=NULL,
Display=TRUE,
Files=NULL)