0
檢索數據
有通過http://opendap.co-ops.nos.noaa.gov/axis/基於R SOAP(SSOAP)從NOAA
library(SSOAP)
pred.wsdl<-"http://opendap.co-ops.nos.noaa.gov/axis/webservices/predictions/wsdl/Predictions.wsdl"
pred.params<-c("8454000","20140702","20140702","MLLW",0,0,60) # from NOAA's java example
# and the docs on http://opendap.co-ops.nos.noaa.gov/axis/webservices/predictions/samples/request.xml
tmp<-processWSDL(pred.wsdl)
ff<-genSOAPClientInterface(def=tmp,verbose=TRUE)
[email protected]$getPredictions(pred.params)
可以從NOAA幾個SOAP服務這得到:
> pred.wsdl<-"http://opendap.co-ops.nos.noaa.gov/axis/webservices/predictions/wsdl/Predictions.wsdl"
> pred.params<-c("8454000","20140702","20140702","MLLW",0,0,60) # from NOAA's java example
> tmp<-processWSDL(pred.wsdl)
> ff<-genSOAPClientInterface(def=tmp,verbose=TRUE)
<defClass> stationId.beginDate.endDate.datum.unit.timeZone.dataInterval
finished stationId.beginDate.endDate.datum.unit.timeZone.dataInterval
<defClass> Data
finished Data
<defClass> ArrayOfData
finished ArrayOfData
<defClass> data
finished data
<defClass> stationId.stationName.latitude.longitude.state.dataSource.COOPSDisclaimer.beginDate.endDate.datum.unit.timeZone.dataInterval.data
finished stationId.stationName.latitude.longitude.state.dataSource.COOPSDisclaimer.beginDate.endDate.datum.unit.timeZone.dataInterval.data
Operation getPredictions
Operation getPredictionsAndMetadata
> [email protected]$getPredictions(pred.params)
Error in as(Parameters, "stationId.beginDate.endDate.datum.unit.timeZone.dataInterval") :
no method or default for coercing 「character」 to 「stationId.beginDate.endDate.datum.unit.timeZone.dataInterval」
>
我似乎無法找到stationId.beginDate.endDate.datum.unit.timeZone.dataInterval類隨處可用來做一個新的(....)。
> getAnywhere(stationId.beginDate.endDate.datum.unit.timeZone.dataInterval)
no object named ‘stationId.beginDate.endDate.datum.unit.timeZone.dataInterval’ was found
ETA:
我發現類的定義:
getClassDef('stationId.beginDate.endDate.datum.unit.timeZone.dataInterval')
當時我能夠來填充一個S對象有:
pred.Sparams=new('stationId.beginDate.endDate.datum.unit.timeZone.dataInterval',stationId=pred.params[1],beginDate=pred.params[2],endDate=pred.params[3],datum=pred.params[4],unit=as.integer(pred.params[5]),timeZone=as.integer(pred.params[6]),dataInterval=as.integer(pred.params[7]))
,並調用它:
pred.dataAOD <- [email protected]$getPredictions(pred.Sparams)
,並把它轉換成更多的東西R-像:
pred.data <- t(mapply([email protected],FUN=function(x){c([email protected],[email protected])},USE.NAMES=FALSE))
head(pred.data)
time pred
[1,] "07/02/2014 00:00" "0.706"
[2,] "07/02/2014 01:00" "0.866"
[3,] "07/02/2014 02:00" "1.078"
[4,] "07/02/2014 03:00" "1.266"
[5,] "07/02/2014 04:00" "1.322"
[6,] "07/02/2014 05:00" "1.192"
如何做任何提示,這更好的?
CRAN不再提供SSOAP軟件包。看起來它不再被支持。您可以使用其他方法來檢索數據,例如http://opendap.co-ops.nos.noaa.gov/ioos-dif-sos/? – MrFlick