# File: LuckiamuteDesign.R # Purpose: Example linear GRTS survey design for Luckiamute Watershed Council streams # Programmer: Tony Olsen # Date: April 17, 2005 ####### # Load psurvey.design library ####### ####### Read in dbf file to get attributes # stream network is in Albers projection. See projection file # Read in dbf file att <- read.dbf("luck-ash") names(att) <- tolower(names(att)) head(att) # look at attributes that will be used to define strata and # unequal probability categories table(att$minor2) # 610 - intermittent stream, 0 - perennial stream table(att$strahler) # Strahler stream order 1=headwater stream # summarize frame stream length (km) by mdcaty sum(att$length)/1000 tapply(att$length, list(att$strahler, att$minor2), sum)/1000 ###### Four Example GRTS designs are given. Each can be run independently. ##### Equal probability GRTS survey design Equaldsgn <- list(None=list(panel=c(Panel_1=50), seltype='Equal')) sample(100000000,1) # run to get random seed dsgntime <- proc.time() Equalsites <- grts(design=Equaldsgn, DesignID='EQUAL', type.frame='linear', src.frame='shapefile', in.shape='luck-ash', att.frame=att, prjfilename='luck-ash', out.shape='Equal Sites') dsgntime <- ( proc.time() - dsgntime )/60 # time in minutes to complete design dsgntime # Note: output dbf file can be read directly into Excel ##### Stratified GRTS survey design with over sample. # create strata variable att$PerInt <- as.factor( att$minor2 ) levels(att$PerInt) <- list(Perennial='0', Intermittent='610') # specify design Stratdsgn <- list(Perennial=list(panel=c(Panel_1=50), seltype='Equal', over=50), Intermittent=list(panel=c(Panel_1=50), seltype='Equal', over=50)) sample(100000000,1) # run to get random seed dsgntime <- proc.time() Stratsites <- grts(design=Stratdsgn, DesignID='STRATIFIED', type.frame='linear', src.frame='shapefile', in.shape='luck-ash', att.frame=att, stratum='PerInt', prjfilename='luck-ash', out.shape='Stratified Sites') dsgntime <- ( proc.time() - dsgntime )/60 # time in minutes to complete design dsgntime ##### Unequal probability GRTS survey design with over sample and stratification. # create strata variable att$PerInt <- as.factor( att$minor2 ) levels(att$PerInt) <- list(Perennial='0', Intermittent='610') # create Strahler categories for unequal probability design att$strahcat <- as.factor(att$strahler) levels(att$strahcat) <- list('1st'=c('0','1'), '2nd'='2', '3rd+'=c('3','4','5') ) Unequaldsgn <- list(Perennial=list(panel=c(Panel_1=75), seltype='Unequal', caty.n=c('1st'=25 , '2nd'=25 ,'3rd+'=25 ), over=36), Intermittent=list(panel=c(Panel_1=25), seltype='Unequal', caty.n=c('1st'=17 , '2nd'=5 ,'3rd+'=3 ), over=0)) sample(100000000,1) # run to get random seed dsgntime <- proc.time() Unequalsites <- grts(design=Unequaldsgn, DesignID='UNEQUAL', type.frame='linear', src.frame='shapefile', in.shape='luck-ash', att.frame=att, stratum='PerInt', mdcaty='strahcat', prjfilename='luck-ash', out.shape='Unequal Sites') dsgntime <- ( proc.time() - dsgntime )/60 # time in minutes to complete design dsgntime ##### Panels for surveys over time with unequal probability GRTS survey # design with over sample and stratification. # create strata variable att$PerInt <- as.factor( att$minor2 ) levels(att$PerInt) <- list(Perennial='0', Intermittent='610') # create Strahler categories for unequal probability design att$strahcat <- as.factor(att$strahler) levels(att$strahcat) <- list('1st'=c('0','1'), '2nd'='2', '3rd+'=c('3','4','5') ) Paneldsgn <- list(Perennial=list(panel=c(Year1=17, Year2=17, YearAll=16),, seltype='Unequal', caty.n=c('1st'=15 , '2nd'=15 ,'3rd+'=20 ), over=50), Intermittent=list(panel=c(YearOnce=25), seltype='Unequal', caty.n=c('1st'=17 , '2nd'=5 ,'3rd+'=3 ), over=0)) sample(100000000,1) # run to get random seed dsgntime <- proc.time() Panelsites <- grts(design=Paneldsgn, DesignID='UNEQUAL', type.frame='linear', src.frame='shapefile', in.shape='luck-ash', att.frame=att, stratum='PerInt', mdcaty='strahcat', prjfilename='luck-ash', out.shape='Panel Sites') dsgntime <- ( proc.time() - dsgntime )/60 # time in minutes to complete design dsgntime # summary of sites addmargins(table( Panelsites$panel, Panelsites$mdcaty, Panelsites$stratum) )