Re: [52N Geostatistics] about sos4R

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: [52N Geostatistics] about sos4R

Daniel Nüst
Dear list!

I received the following question about the 52N project sos4R which I'd
like to save here for future users.

@Alessandro: Have you subscribed to the mailing list yet?

On 16.11.2010 00:12, Alessandro Oggioni wrote:

> ise <- SOS("http://sos.ise.cnr.it/sos")
> ise
> # Offering
> ise.offerings <- sosOfferings(ise)
> ise.offerings
> # getObservation in SOS
> ise_air_temp <- getObservation(sos = ise, offering =
> ise.offerings[["air_temperature"]])
> ise_air_temp
>
> R return this error:
>
> Error in .valParser(values = obj[[sweValuesName]], fields = .fields,
> encoding = .encoding,  :
>   No converter found!
> Warning message:
> In .valParser(values = obj[[sweValuesName]], fields = .fields,
> encoding = .encoding,  :
>   No converter for the unit of measurement  Cel degree  with the
> definition  urn:ogc:def:property:OGC:1.0.30:air_temp ! Trying a
> default, but you can add one when creating a SOS using
> SosDataFieldConvertingFunctions().
> Why?
That is sort of an expected error. The parser tries to determine whether
a value is of type string of double (for now) based on the identifier or
unit of measurement of a field.

In you case that is:

[...]
<swe:field name="urn:ogc:def:property:OGC:1.0.30:air_temp">
                <swe:Quantity
definition="urn:ogc:def:property:OGC:1.0.30:air_temp">
                  <swe:uom code="Cel degree"/>
                </swe:Quantity>
              </swe:field>
[...]

But since I cannot foresee all possible field definitions, I give you as
a user the possibility to add your own converters - which in most cases
will just be reusing one of the existing. The following code solves your
problem:

# add a conversion function for the field definition "...:air_temp"
ise.converters <-
SosDataFieldConvertingFunctions("urn:ogc:def:property:OGC:1.0.30:air_temp"
= sosConvertDouble)
ise <- SOS("http://sos.ise.cnr.it/sos", dataFieldConverters =
ise.converters)

# Offering
ise.offerings <- sosOfferings(ise)

# getObservation in SOS
ise_air_temp <- getObservation(sos = ise,
                offering = ise.offerings[["air_temperature"]])
ise_air_temp
ise_air_temp.result <- sosResult(ise_air_temp)
summary(ise_air_temp.result)

You can also check out the examples section on the help page

?SosDataFieldConvertingFunctions


Please be aware that 'Cel degree' is not a valid unit of measurement.
You can check these out at UCUM [1]. The previously tested offering
"rain" worked for me because it's unit of measurement is <swe:uom
code="mm"/>, and "mm" already is an entry in the default converter list.
You can inspect the default converters:

names(SosDataFieldConvertingFunctions())
SosDataFieldConvertingFunctions()

But this naturally is not a complete list!

Regards,
Daniel

[1] http://aurora.regenstrief.org/~ucum/ucum.html


_______________________________________________
Geostatistics mailing list
[hidden email]
http://list.52north.org/mailman/listinfo/geostatistics
http://geostatistics.forum.52north.org

signature.asc (270 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [52N Geostatistics] about sos4R

Alessandro
Hi Daniel,
many thanks!
I have another question about the possibility of sos4R packages.
I have used your demo: weathersos, airquality, pagel and marinemeta
looking the creation of the request with standard parameters. But none
exists in a request that includes the feature or parameter FOI.
It's possible include feature or FOI in this request? Have you an example?
Best regards
Alessandro


2010/11/16 Daniel Nüst <[hidden email]>:

> Dear list!
>
> I received the following question about the 52N project sos4R which I'd
> like to save here for future users.
>
> @Alessandro: Have you subscribed to the mailing list yet?
>
> On 16.11.2010 00:12, Alessandro Oggioni wrote:
>> ise <- SOS("http://sos.ise.cnr.it/sos")
>> ise
>> # Offering
>> ise.offerings <- sosOfferings(ise)
>> ise.offerings
>> # getObservation in SOS
>> ise_air_temp <- getObservation(sos = ise, offering =
>> ise.offerings[["air_temperature"]])
>> ise_air_temp
>>
>> R return this error:
>>
>> Error in .valParser(values = obj[[sweValuesName]], fields = .fields,
>> encoding = .encoding,  :
>>   No converter found!
>> Warning message:
>> In .valParser(values = obj[[sweValuesName]], fields = .fields,
>> encoding = .encoding,  :
>>   No converter for the unit of measurement  Cel degree  with the
>> definition  urn:ogc:def:property:OGC:1.0.30:air_temp ! Trying a
>> default, but you can add one when creating a SOS using
>> SosDataFieldConvertingFunctions().
>> Why?
>
> That is sort of an expected error. The parser tries to determine whether
> a value is of type string of double (for now) based on the identifier or
> unit of measurement of a field.
>
> In you case that is:
>
> [...]
> <swe:field name="urn:ogc:def:property:OGC:1.0.30:air_temp">
>                <swe:Quantity
> definition="urn:ogc:def:property:OGC:1.0.30:air_temp">
>                  <swe:uom code="Cel degree"/>
>                </swe:Quantity>
>              </swe:field>
> [...]
>
> But since I cannot foresee all possible field definitions, I give you as
> a user the possibility to add your own converters - which in most cases
> will just be reusing one of the existing. The following code solves your
> problem:
>
> # add a conversion function for the field definition "...:air_temp"
> ise.converters <-
> SosDataFieldConvertingFunctions("urn:ogc:def:property:OGC:1.0.30:air_temp"
> = sosConvertDouble)
> ise <- SOS("http://sos.ise.cnr.it/sos", dataFieldConverters =
> ise.converters)
>
> # Offering
> ise.offerings <- sosOfferings(ise)
>
> # getObservation in SOS
> ise_air_temp <- getObservation(sos = ise,
>                offering = ise.offerings[["air_temperature"]])
> ise_air_temp
> ise_air_temp.result <- sosResult(ise_air_temp)
> summary(ise_air_temp.result)
>
> You can also check out the examples section on the help page
>
> ?SosDataFieldConvertingFunctions
>
>
> Please be aware that 'Cel degree' is not a valid unit of measurement.
> You can check these out at UCUM [1]. The previously tested offering
> "rain" worked for me because it's unit of measurement is <swe:uom
> code="mm"/>, and "mm" already is an entry in the default converter list.
> You can inspect the default converters:
>
> names(SosDataFieldConvertingFunctions())
> SosDataFieldConvertingFunctions()
>
> But this naturally is not a complete list!
>
> Regards,
> Daniel
>
> [1] http://aurora.regenstrief.org/~ucum/ucum.html
>
>
_______________________________________________
Geostatistics mailing list
[hidden email]
http://list.52north.org/mailman/listinfo/geostatistics
http://geostatistics.forum.52north.org
Reply | Threaded
Open this post in threaded view
|

Re: [52N Geostatistics] about sos4R

Daniel Nüst
On 18.11.2010 14:19, Alessandro Oggioni wrote:
> I have another question about the possibility of sos4R packages.
> I have used your demo: weathersos, airquality, pagel and marinemeta
> looking the creation of the request with standard parameters. But none
> exists in a request that includes the feature or parameter FOI.
> It's possible include feature or FOI in this request? Have you an example?

Yes, but only rudimentary at the moment, as the feature can be a lot of
things:

Have a look at ?SosFeatureOfInterest

Currently, requests with feature IDs and bounding boxes are supported,
see examples below. If you have a specific spatial feature elements you
want to try out, let me know!

Sadly, the last query returns an error that I cannot solve right now as
I'm leaving for the weekend. Let me know if you can solve it, otherwise
I'll look into it on Monday.


/Daniel



ise.converters <-
SosDataFieldConvertingFunctions("urn:ogc:def:property:OGC:1.0.30:air_temp"
= sosConvertDouble)
ise <- SOS("http://sos.ise.cnr.it/sos", dataFieldConverters =
ise.converters)
ise.offerings <- sosOfferings(ise)

# request with features of interest
ise.rain.features <- sosFeaturesOfInterest(ise.offerings[["rain"]])

# feature id
ise.rain2 <- getObservation(sos = ise,
                offering = ise.offerings[["rain"]],
                featureOfInterest =  SosFeatureOfInterest(objectIDs = ise.rain.features),
                inspect = TRUE)

# spatial filtering: check out ?sos4R::OGC
bbox <- sosCreateBBOX(lowLat = 10.0, lowLon = 2.0, uppLat = 30.0, uppLon
= 5.0,
                        srsName = "urn:ogc:def:crs:EPSG:4326")
ise.rain3 <- getObservation(sos = ise,
                offering = ise.offerings[["rain"]],
                featureOfInterest = SosFeatureOfInterest(spatialOps = bbox),
                inspect = TRUE)


_______________________________________________
Geostatistics mailing list
[hidden email]
http://list.52north.org/mailman/listinfo/geostatistics
http://geostatistics.forum.52north.org

signature.asc (270 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [52N Geostatistics] about sos4R

Alessandro
Hi Daniel and all,
I have tried your script about the FeatureOfInterset and of course I have solved my problem! :-)
Thanks!!
But I have a new question to the list!
I have produced a SOS with a 3D observations: same mobile sensor (about 27 stations) that change with depth (from 0 to - 40 m) and in each depth I have an observation.
For this sensor is important, in R, to have coordinates of each station for produce a 3D plot or other 3D figures. I have composed a request using this script
...
# SOS
ise <- SOS("http://sos.ise.cnr.it/sos")
ise

# Offering
ise.offerings <- sosOfferings(ise)
ise.offerings

# add a conversion function for the field definition "...:chla_conc"
ise_chla.converters <-
SosDataFieldConvertingFunctions("urn:ogc:def:property:OGC:1.0.30:chla_conc"
= sosConvertDouble)
ise <- SOS("http://sos.ise.cnr.it/sos", dataFieldConverters =
ise_chla.converters)
ise

# set up request parameters
sosProcedures(ise)
station_ise_chla <- sosProcedures(ise)[[5]] # [[5]] mean second procedures: total_chla_FP
station_ise_chla
sosOfferings(ise)
Offering_ise_chla <- sosOfferings(ise)[["total_chla_FP"]]
Offering_ise_chla
ise.chla.features <- sosFeaturesOfInterest(ise.offerings[["total_chla_FP"]])
# spatial filtering: check out
ise.chla.features <- SosFeatureOfInterest(objectIDs = ise.chla.features[1:11])
ise.chla.features
ise_chla_time <- sosCreateTimePeriod(sos = ise,
               begin = as.POSIXct("2005-08-30 00:00"),
               end = as.POSIXct("2005-08-30 23:00"))
ise_chla_time

# make the request
obs_ise_chla <- getObservation(sos = ise,
            procedure = station_ise_chla,
              offering = Offering_ise_chla,
                        featureOfInterest = ise.chla.features,
                        eventTime = sosCreateEventTimeList(ise_chla_time),
                        inspect = TRUE)
                       
data_ise_chla <- sosResult(obs_ise_chla)
data_ise_chla
...
and in data_ise_chla I have, for each observations, concentration of clorophyll, depth and feature, but I don't have the coordinates of FOIs.
How do I to have in results also the coordinates?
Thanks you in advance
Alessandro
Reply | Threaded
Open this post in threaded view
|

[52N Geostatistics] sos4R: add coordinates from observations to results --- Was: Re: about sos4R

Daniel Nüst
On 22.11.2010 09:09, Alessandro wrote:

> I have produced a SOS with a 3D observations: same mobile sensor (about 27
> stations) that change with depth (from 0 to - 40 m) and in each depth I have
> an observation.
> For this sensor is important, in R, to have coordinates of each station for
> produce a 3D plot or other 3D figures. I have composed a request using this
> script
> ...
> # SOS
> ise <- SOS("http://sos.ise.cnr.it/sos")
> ise
>
> # Offering
> ise.offerings <- sosOfferings(ise)
> ise.offerings
>
> # add a conversion function for the field definition "...:chla_conc"
> ise_chla.converters <-
> SosDataFieldConvertingFunctions("urn:ogc:def:property:OGC:1.0.30:chla_conc"
> = sosConvertDouble)
> ise <- SOS("http://sos.ise.cnr.it/sos", dataFieldConverters =
> ise_chla.converters)
> ise
>
> # set up request parameters
> sosProcedures(ise)
> station_ise_chla <- sosProcedures(ise)[[5]] # [[5]] mean second procedures:
> total_chla_FP
> station_ise_chla
> sosOfferings(ise)
> Offering_ise_chla <- sosOfferings(ise)[["total_chla_FP"]]
> Offering_ise_chla
> ise.chla.features <- sosFeaturesOfInterest(ise.offerings[["total_chla_FP"]])
> # spatial filtering: check out
> ise.chla.features <- SosFeatureOfInterest(objectIDs =
> ise.chla.features[1:11])
> ise.chla.features
> ise_chla_time <- sosCreateTimePeriod(sos = ise,
>                begin = as.POSIXct("2005-08-30 00:00"),
>                end = as.POSIXct("2005-08-30 23:00"))
> ise_chla_time
>
> # make the request
> obs_ise_chla <- getObservation(sos = ise,
>             procedure = station_ise_chla,
>               offering = Offering_ise_chla,
> featureOfInterest = ise.chla.features,
> eventTime = sosCreateEventTimeList(ise_chla_time),
> inspect = TRUE)
>
> data_ise_chla <- sosResult(obs_ise_chla)
> data_ise_chla
> ...
> and in data_ise_chla I have, for each observations, concentration of
> clorophyll, depth and feature, but I don't have the coordinates of FOIs.
> How do I to have in results also the coordinates?
You can extract the positions from an Observation/ObservationCollection
along with the foi ID with the function sosCoordinates(...). The code:


# extract the positions
coords_ise_chla <- sosCoordinates(obs_ise_chla)

# attach the positions to the data frame
data_coords_ise_chla <- merge(x = data_ise_chla, y = coords_ise_chla,
                by.x = "feature", by.y = "foi_id")

# some example rows of the merged data.frame
data_coords_ise_chla[c(1:3, 101:103, 301:303),]

[One remark: I changed the default value of the column for the feature
id to "feature" for sosCoordinates(...) in the SVN, so if you work with
that version, the manual setting of the matching columns is not required
anymore. Watch out for that chance if you install a new release.]

I don't know your data well, so please check thoroughly if the merged
result is OK. Please also let me know how that analysis works out
(especially if you produce a nice plot)!

/Daniel


_______________________________________________
Geostatistics mailing list
[hidden email]
http://list.52north.org/mailman/listinfo/geostatistics
http://geostatistics.forum.52north.org

signature.asc (270 bytes) Download Attachment