Created
July 13, 2015 03:22
-
-
Save allixender/505dd2e17d0d9c026da8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(gstat) | |
library(sos4R) | |
gwl.converters <- SosDataFieldConvertingFunctions( | |
"http://resources.smart-project.info/gemet/groundwaterlevel" = sosConvertDouble, | |
"http://www.opengis.net/def/property/OGC/0/SamplingTime" = sosConvertTime, | |
"http://www.opengis.net/def/property/OGC/0/FeatureOfInterest" = sosConvertString) | |
gwl <- SOS(url = "http://portal.smart-project.info/52nSOSv3.5.0/sos", | |
dataFieldConverters = gwl.converters) | |
# summary(gwl) | |
gwl_offerings <- sosOfferings(gwl) | |
#names(gwl_offerings) | |
crs <- sosGetCRS(gwl) | |
gwl_off_no2 <- gwl_offerings[[2]] | |
#summary(gwl_off_no2) | |
year1990 = sosCreateTime(sos = gwl, time = "1990/01/01::1990/12/31") | |
year1991 = sosCreateTime(sos = gwl, time = "1991/01/01::1991/12/31") | |
year1992 = sosCreateTime(sos = gwl, time = "1992/01/01::1992/12/31") | |
year1993 = sosCreateTime(sos = gwl, time = "1993/01/01::1993/12/31") | |
year1994 = sosCreateTime(sos = gwl, time = "1994/01/01::1994/12/31") | |
year1995 = sosCreateTime(sos = gwl, time = "1995/01/01::1995/12/31") | |
year1996 = sosCreateTime(sos = gwl, time = "1996/01/01::1996/12/31") | |
year1997 = sosCreateTime(sos = gwl, time = "1997/01/01::1997/12/31") | |
year1998 = sosCreateTime(sos = gwl, time = "1998/01/01::1998/12/31") | |
year1999 = sosCreateTime(sos = gwl, time = "1999/01/01::1999/12/31") | |
year2000 = sosCreateTime(sos = gwl, time = "2000/01/01::2000/12/31") | |
year2001 = sosCreateTime(sos = gwl, time = "2001/01/01::2001/12/31") | |
year2002 = sosCreateTime(sos = gwl, time = "2002/01/01::2002/12/31") | |
year2003 = sosCreateTime(sos = gwl, time = "2003/01/01::2003/12/31") | |
year2004 = sosCreateTime(sos = gwl, time = "2004/01/01::2004/12/31") | |
year2005 = sosCreateTime(sos = gwl, time = "2005/01/01::2005/12/31") | |
year2006 = sosCreateTime(sos = gwl, time = "2006/01/01::2006/12/31") | |
year2007 = sosCreateTime(sos = gwl, time = "2007/01/01::2007/12/31") | |
year2008 = sosCreateTime(sos = gwl, time = "2008/01/01::2008/12/31") | |
year2009 = sosCreateTime(sos = gwl, time = "2009/01/01::2009/12/31") | |
year2010 = sosCreateTime(sos = gwl, time = "2010/01/01::2010/12/31") | |
c("soe_352007", | |
"soe_352051", | |
"soe_352111", | |
"soe_352131", | |
"soe_352271", | |
"soe_352311", | |
"soe_353291", | |
"soe_361003", | |
"soe_361041", | |
"soe_362003", | |
"soe_362005", | |
"soe_362017", | |
"soe_362033", | |
"soe_362331", | |
"soe_362541", | |
"soe_362551", | |
"soe_362661", | |
"soe_362711", | |
"soe_362951", | |
"soe_362511", | |
"soe_362521", | |
"soe_363251", | |
"soe_372061") | |
observ<-getObservation(sos = gwl, offering=gwl_off_no2, saveOriginal = TRUE, eventTime = year2000) | |
result<-sosResult(observ, coordinates = TRUE) | |
#summary(result) | |
#timePos <- colnames(result)[[1]] | |
measLevel <- colnames(result)[[2]] | |
foiid <- colnames(result)[[6]] | |
#subset(result, feature=="soe_362551") | |
#plot(result[["SamplingTime"]], result[[measLevel]]) | |
#res1<-subset(result, feature=="soe_362551") | |
#plot(res1[["SamplingTime"]], res1[[measLevel]]) | |
obs.crs<-sosGetCRS(observ) | |
#obs.crs | |
gwl_spdf<-SpatialPointsDataFrame(coords = result[,c("lon", "lat")],data = result[,c("SamplingTime", "feature", measLevel)],proj4string = obs.crs) | |
#bbox(gwl_spdf) | |
#summary(gwl_spdf) | |
gwl_spdf_sc <- as(observ, "SpatialPointsDataFrame") | |
#summary(gwl_spdf_sc) | |
library(spacetime) | |
#class(gwl_spdf_sc) | |
#image(gwl_spdf_sc["groundwaterlevel"]) | |
#result | |
gs_data <- result | |
#summary(gs_data) | |
#class(gs_data) | |
#coordinates(gs_data) | |
#coordinates(gs_data)[3:4,] | |
bubble(gwl_spdf_sc, measLevel, col=c("#00ff0088", "#00ff0088"), main = "gwl masl (m)") | |
library(akima) | |
x <- result[["lat"]] | |
y <- result[["lon"]] | |
z <- result[[measLevel]] | |
matr <- interp(x,y,z) | |
#matr | |
library(fields) | |
#gridded(matr) | |
#spplot(matr) | |
zr<-range(result[[measLevel]]) | |
matr <- interp(x,y,z, duplicate = "mean", linear = TRUE) | |
image.plot(matr, zlim = zr) | |
## http://data-dev.gns.cri.nz/ngmp-sos/ | |
## http://localhost:9090/ngmp-sos/sos | |
## http://data.gns.cri.nz/ggwdata/phenomenon/groundwaterlevel 6 | |
## http://data.gns.cri.nz/ggwdata/phenomenon/conductivity 4 | |
gw_surface_time <- function ( year) { | |
library(sos4R) | |
library(akima) | |
library(fields) | |
gwl.converters <- SosDataFieldConvertingFunctions( | |
"http://data.gns.cri.nz/ggwdata/phenomenon/groundwaterlevel" = sosConvertDouble, | |
"http://www.opengis.net/def/property/OGC/0/SamplingTime" = sosConvertTime, | |
"http://www.opengis.net/def/property/OGC/0/FeatureOfInterest" = sosConvertString) | |
gwl <- SOS(url = "http://portal.smart-project.info/52nSOSv3.5.0/sos", | |
dataFieldConverters = gwl.converters) | |
# > myopts <- curlOptions(ssl.verifyhost=FALSE, ssl.verifypeer=FALSE, followlocation=TRUE) | |
# > handle <- getCurlHandle( .opts= myopts) | |
# > gwl <- SOS(url = "https://geier.gns.cri.nz/ngmp-sos/sos" , dataFieldConverters = gwl.converters, curlHandle=handle) | |
gwl_offerings <- sosOfferings(gwl) | |
gwl_off_no2 <- gwl_offerings[[2]] | |
observ<-getObservation(sos = gwl, offering=gwl_off_no2, saveOriginal = FALSE, eventTime = year) | |
result<-sosResult(observ, coordinates = TRUE) | |
measLevel <- colnames(result)[[2]] | |
obs.crs<-sosGetCRS(observ) | |
gwl_spdf<-SpatialPointsDataFrame(coords = result[,c("lon", "lat")],data = result[,c("SamplingTime", "feature", measLevel)],proj4string = obs.crs) | |
gwl_spdf_sc <- as(observ, "SpatialPointsDataFrame") | |
# bubble(gwl_spdf_sc, measLevel, col=c("#00ff0088", "#00ff0088"), main = "gwl masl (m)") | |
x <- result[["lat"]] | |
y <- result[["lon"]] | |
z <- result[[measLevel]] | |
matr <- interp(x,y,z, duplicate = "mean", linear = TRUE) | |
# zr<-range(result[[measLevel]]) | |
zr<-range(c(0, 50)) | |
image.plot(matr, zlim = zr ) | |
points(gwl_spdf_sc, pch = 19) | |
return(matr) | |
} | |
# groundwaterlevel (masl), mean 1991 | |
######################## | |
library(sos4R) | |
# http://sdf.ndbc.noaa.gov/sos/server.php | |
# "http://data.gns.cri.nz/ggwdata/phenomenon/dissolved_iron | |
# http://resources.smart-project.info/ggwdata/phenomenon/dissolved_iron | |
# offering station-vqsp4 | |
gwl.converters <- SosDataFieldConvertingFunctions( | |
"http://resources.smart-project.info/ggwdata/phenomenon/dissolved_iron" = sosConvertDouble, | |
"http://www.opengis.net/def/property/OGC/0/SamplingTime" = sosConvertTime, | |
"http://www.opengis.net/def/property/OGC/0/FeatureOfInterest" = sosConvertString) | |
gwl <- SOS(url = "http://localhost:9090/ngmp-sos/sos" , dataFieldConverters = gwl.converters) | |
gwl_offerings <- sosOfferings(gwl) | |
gwl_off_no2 <- gwl_offerings[["NGMP_DISSOLVED_IRON"]] | |
year2000 = sosCreateTime(sos = gwl, time = "2000/01/01::2000/12/31") | |
observ<-getObservation(sos = gwl, offering=gwl_off_no2, saveOriginal = FALSE, eventTime = year2000) | |
result<-sosResult(observ, coordinates = TRUE) | |
measLevel <- colnames(result)[[2]] | |
zr<-range(result[[measLevel]]) | |
foiid <- colnames(result)[[6]] | |
obs.crs<-sosGetCRS(observ) | |
gwl_spdf<-SpatialPointsDataFrame(coords = result[,c("lon", "lat")],data = result[,c("SamplingTime", "feature", measLevel)],proj4string = obs.crs) | |
gwl_spdf_sc <- as(observ, "SpatialPointsDataFrame") | |
bubble(gwl_spdf_sc, measLevel, col=c("#00ff0088", "#00ff0088"), main = "gwl masl (m)") | |
res1<-subset(result, feature==„FEATURE_ID") | |
plot(res1[[4]]) | |
fit <- lm(some ~ model) | |
png(filename="your/file/location/name.png") | |
plot(fit) | |
dev.off() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment