R/genBiweekMeteos.R

Defines functions genBiweekMeteos extractBiweekMegteos

Documented in genBiweekMeteos

#' @title genBiweekMeteos
#'
#' @description This function is to use the biweekly averages of meteorological meters on the server side.
#'
#' @param sublocs : spatial points data frame of the subject locations for geocoding the location
#'
#' @param  tarVar: the target meteorological variable name
#'
#' @param  dname:the target meteorological variable channel name in the image file
#'
#' @param  sub_locs: Starting index of the models to be used to make the prediction
#'
#' @param  subgid: id name
#'
#' @param  flag: the flag for later join
#'
#' @param  from_biwk: start biweek id
#'
#' @param  to_biwk: end biweek id
#'
#' @param  start_date: start date
#'
#' @return NULL.  All the generated values saved in the server side for later extraction.
#'
#' @export genBiweekMeteos
#'
#'
genBiweekMeteos=function(sublocs,tarVar="pr",dname="precipitation_amount",subgid="geoid_latlongt",flag="precip",
                         from_biwk=1,to_biwk=574, start_date="1992-01-01"   ){

#  sublocs=geoinput2;tarVar="tmmn";dname="air_temperature";subgid="geoid_latlongt";joinflag="schooldt";
#  from_biwk=1; to_biwk=30; start_date="1992-01-01"
  sublocs_prj=sp::spTransform(sublocs,"+proj=longlat +datum=WGS84")
  conn=RSclient::RS.connect(host="noxchs2.usc.edu",port =5501)
  RSclient::RS.assign(conn,"tarVar",tarVar)
  RSclient::RS.assign(conn,"dname",dname)
  RSclient::RS.assign(conn,"sublocs_prj",sublocs_prj)
  RSclient::RS.assign(conn,"subgid",subgid)
  RSclient::RS.assign(conn,"flag",flag)
  RSclient::RS.assign(conn,"from_biwk",from_biwk)
  RSclient::RS.assign(conn,"to_biwk",to_biwk)
  RSclient::RS.assign(conn,"start_date",start_date)
  RSclient::RS.eval(conn,getAvgBiweekCus(tarVar=tarVar,dname=dname,sub_locs=sublocs_prj,
                        subgid=subgid,flag=flag, from_biwk=from_biwk,to_biwk=to_biwk,
                        start_date=start_date),lazy=TRUE)
  RSclient::RS.close(conn)
}


#' @title extarctBiweekMegteos
#'
#' @description This function is to extract the biweekly averages of meteorological meters for the subject locations.
#'
#' @param dfInput : data frame for subject locations
#'
#' @param  nVar: the target name given by the users
#'
#' @param  flag:the flag for join generated by genBiweekMeteos
#'
#' @param  from_biwk: start biweek id
#'
#' @param  to_biwk: end biweek id
#'
#' @param subgid: id name
#'
#' @param  start_date: start date
#'
#' @return values of meteorological variable extracted.
#'
#' @export extarctBiweekMegteos
#'s

extractBiweekMegteos=function(dfInput=dfInput,nVar="precip33",flag="precip",from_biwk=1,
                              to_biwk=10,subgid="geoid_latlongt"){
  conn=RSclient::RS.connect(host="noxchs2.usc.edu",port =5501)
  RSclient::RS.assign(conn,"dfInput",dfInput)
  RSclient::RS.assign(conn,"nVar",nVar)
  RSclient::RS.assign(conn,"flag",flag)
  RSclient::RS.assign(conn,"from_biwk",from_biwk)
  RSclient::RS.assign(conn,"to_biwk",to_biwk)
  RSclient::RS.assign(conn,"subgid",subgid)
  res=RSclient::RS.eval(conn,getMeterTimeline(dfInput,nVar,flag,from_biwk,to_biwk,subgid))
  RSclient::RS.close(conn)
  return(res)
}
lspatial/sptemUS documentation built on May 29, 2019, 3:42 a.m.