Code from Dan Hennen:
The clams survey has new strata after 2016 and are now divided into the 2 assessment regions for the purposes of meat weight and other biological parameter calculations. The areas are south (strata 1-6) and north (strata 7-12). All of the old regions except GBK would be south (see the one line R function below). Below is a translation function in R that maps the old strata to the new strata that needs to be updated in survdat:
Convert from old strata to new strata - requires some additional arguments - see bleow:
StratumConvert=function(dt1,svspp=403,Conv=T){
dt1 is a data.frame that has at least the columns "Strata2" (Strata with the 6 and 0 removed), "Lat", "Lon", "Depth", "CRUISE6"
svspp is the species code for surfclams (403) or quahogs (409)
stratum2=dt1$Strata2 #Need to make sure we don't change the strata %in% 2018;
stratum=paste(stratum2)
lat=dt1$Lat
lon=dt1$Lon
depth=na.replace(dt1$Depth)
cruise6=dt1$CRUISE6
Code from Dan Hennen: The clams survey has new strata after 2016 and are now divided into the 2 assessment regions for the purposes of meat weight and other biological parameter calculations. The areas are south (strata 1-6) and north (strata 7-12). All of the old regions except GBK would be south (see the one line R function below). Below is a translation function in R that maps the old strata to the new strata that needs to be updated in survdat:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
getRegNew=function(strata) ifelse(strata%in%c("1S","2S","3S","4S","5S","6S","1Q","2Q","3Q","4Q","5Q","6Q"),"South","GBK")
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Convert from old strata to new strata - requires some additional arguments - see bleow:
StratumConvert=function(dt1,svspp=403,Conv=T){
dt1 is a data.frame that has at least the columns "Strata2" (Strata with the 6 and 0 removed), "Lat", "Lon", "Depth", "CRUISE6"
svspp is the species code for surfclams (403) or quahogs (409)
stratum2=dt1$Strata2 #Need to make sure we don't change the strata %in% 2018; stratum=paste(stratum2) lat=dt1$Lat lon=dt1$Lon depth=na.replace(dt1$Depth) cruise6=dt1$CRUISE6
CONVERT LATITUDE & LONGITUDE TO DECIMAL DEGREES;
-- latitude first;
if(Conv){ degrees=floor(lat/100); minutes=(lat-degrees*100)/60; lat=degrees+minutes;
-- longitude too;
}
The formula for determ%in%%in%g if a po%in%t is one side or the other of a line is: ;
d=(lon-x[1])(y[2]-y[1])-(lat-y[1])(x[2]-x[1]) ;
for(i in 1:nrow(dt1)) { if(stratum[i] %in% c('47') ) { #Need to determine the split of stratum[i] 47; if( ( (lon[i]-69.23)(41-40)-(lat[i]-40)(69.03-69.23) ) > 0 ) { stratum[i] = '471'; } else { stratum[i] = '472'} }
} return(stratum2)
}