I'm trying to implement WaterML2 output for my sensor network webservice. Currently I report sensor data where the data includes IDs for each sensor, time of sensor readings, units and, optionally, GPS data. Typical output looks like the following:

PackageID   TimeStamp   TimeZone    RelayID SensorID    SensorType  Units   Data    Longitude   Latitude    Altitude    Speed   Climb   Track   LongitudeError  LatitudeError   AltitudeError   SpeedError  ClimbError  TrackError
210 2014-04-23 20:36:45.728 UTC SumitTest01 FFF34E141400    Temperature C   24.125  11.574138333    50.924998333    228.2   0.0 0.0 10.57   17.626  16.966  48.22   33.27       
209 2014-04-23 20:36:28.978 UTC SumitTest01 FFF34E141400    Temperature C   24.1875                                             
208 2014-04-23 20:29:33.004 UTC SumitTest01 FFF34E141400    Temperature C   23.625                                              
207 2014-04-23 20:29:14.503 UTC SumitTest01 FFF34E141400    Temperature C   23.625  

SensorType can be Temperature, Humidity, pH with more to come as we add more sensors.

A few years ago we looked at implementing WaterML1, but the specification was confusing and we decided against it. I've been at talks since where researchers have really pushed WaterML2 and one person even told me how it fixed a lot of problems with the confusion in WaterML1.

I've been looking at the specification and examples. It looks pretty straightforward, but I can't seem to find any libraries that can handle the models and XML generation for me in Java (my web service is written in Scala and I can use any Java library).

I've found the following Maven artefact (sbt include):

"org.jvnet.ogc" % "waterml-v_2_0" % "2.2.0"

...but no documentation on it. I've looked through the jar file and it just seems to be automatically generated jaxb stubs.

So my question is, are there any Java/Scala libraries out there that can help me create WaterML2 using a simple API so I don't have to write my own generator in scala.xml/jdom/etc?

If not, are there better examples out there for simple data that only deals with readings (like Temperature) and fixed GPS data points? How would I deal with the accuracy measures in my sample set I get from the GPS? Can those be represented or should I just discard them?

TL;DR Are there any good Scala/Java libraries to help generate WaterML2 and, if not, where are more examples of creating WaterML2 for point/sensor data?

1 Answer 1


In terms of helper libraries for creating XML encodings, you could take a look at https://github.com/highsource/ogc-schemas, which creates JAXB bindings for OGC schemas.

For examples of WaterML2.0 encodings, you could look at the USGS Water Data Services. Here's an example request/response from their REST service. You can create any example using their HTML test tool.

There are also examples in the OGC Schema repository (I can't post any more than two links).

These all have examples that will match your requirements. In terms of accuracy - it depends on whether you want to encode accuracy of measurements, which is possible using the time-value pair metadata. Or you can describe accuracy of spatial positioning using the positionalAccuracy property of the sampling point. See observations & measurements XML (which WaterML2.0 imports).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.