Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm experimenting with MapServer and SOS but I'm not getting back any useful data from the GetObservation call I'm doing. My .map file uses a Postgres query to get data and when I run that same query in PGAdmin I get the four columns I expect: id, geom, date and total_alkalinity_value. All the columns have the right data. Below is the getObservation response in which I see only the gml:boundedBy and ms:msGeometry values, no sign of the id or total_alkalinity_value.

<om:ObservationCollection xmlns:gml="" xmlns:ows="" xmlns:swe="" xmlns:xlink="" xmlns:xsi="" xmlns:sos="" xmlns:ms="" xmlns:om="" gml:id="WQIS_TOTAL_ALKALINITY" xsi:schemaLocation=";version=1.1.0&amp;request=DescribeFeatureType&amp;typename=total_alkalinity">
  <om:procedure xlink:href="urn:ogc:def:procedure:80"/>
    <swe:CompositePhenomenon gml:id="total_alkalinity_value" dimension="3">
      <swe:component xlink:href="urn:ogc:def:property:OGC-SWE:1:id"/>
      <swe:component xlink:href="urn:ogc:def:property:OGC-SWE:1:date"/>
      <swe:component xlink:href="urn:ogc:def:property:OGC-SWE:1:total_alkalinity_value"/>
  <om:featureOfInterest xlink:href=";version=1.1.0&amp;request=DescribeFeatureType&amp;typename=total_alkalinity"/>
          <gml:Envelope srsName="urn:ogc:crs:epsg:4326" srsDimension="2">
            <gml:lowerCorner>167.294382 -46.243591</gml:lowerCorner>
            <gml:upperCorner>167.294382 -46.243591</gml:upperCorner>
          <gml:Point srsName="urn:ogc:crs:epsg:4326" srsDimension="2">
            <gml:pos>167.294382 -46.243591</gml:pos>

And here is the relevant stuff from the layer part of the .map file LAYER .... METADATA .... "sos_timeitem" "date" "sos_procedure" "ALKALINITY_SENSOR" "sos_procedure_item" "total_alkalinity_value" "sos_offering_id" "WQIS_TOTAL_ALKALINITY" "sos_observedproperty_id" "Total Alkalinity" "sos_describesensor_url" ""

NAME "total_alkalinity"

DATA "geom from (
    SELECT AS id,
         l.geom AS geom,
         CASE WHEN COALESCE ((se.start_date).month, 0) = 0
              WHEN COALESCE ((se.start_date).day, 0) = 0
                (se.start_date).year || '-' || (se.start_date).month || '-01'
                (se.start_date).year || '-' || (se.start_date).month || '-' || (se.start_date).day
         END::DATE AS date,
         av.value::NUMERIC AS total_alkalinity_value

So my question is: How do I get id and total_alkalinity_value in my getObservation response?

*updated to show more of the .map file and add sos_dateitem*

*Now that I have the sos_procedure_item set to total_alkalinity_value the om:procedure element contains the data value (in this response it is 80), but that seems like totally the wrong place for it*

share|improve this question
up vote 0 down vote accepted

Ive not worked with the SOS Server, but it looks like it needs to have METADATA configured to work correctly as with the rest of the OGC services. If these have not been set or are incorrect then attributes can go missing.

At the top of your MAP file you need the following in the WEB section:

  "sos_onlineresource" "" ## REQUIRED
  "sos_title"          "My SOS Demo Server" ## Recommended
  "sos_srs"            "EPSG:4326" ## REQUIRED
  "sos_enable_request" "*" # Necessary

And also METADATA in the LAYER definition:

    NAME "test_sos_layer"
      "sos_timeitem" "DATE"  # YOUR DATE FIELD
      "sos_procedure"  "NS01EE0014" ## REQUIRED
      "sos_offering_id" "WQ1289" ## REQUIRED
      "sos_observedproperty_id" "Water Quality" ## REQUIRED
      "sos_describesensor_url" "http://some/url/NS01EE0014.xml" ## REQUIRED

A more detailed way to see what should be happening is to look at the MapServer unit tests. For example the following MAP file:

Should produce the following output for a getObservation request:

Based on the obs.shp shapefile in:

The same test data can be seen in the CSV file at:

Try this example, and gradually change the definitions to match your data. If you really want to find out what is happening then browse the sourcecode or run with a debugger on the source.

share|improve this answer
I was missing the sos_timeitem metadata but I had the rest. With that one added I now get a samplingTime element in the response (I've updated the question to show this) but still no data value. I also added sos_procedure_item even though it is optional so it should work without it. That only served to change the procedure to "80" instead of "ALKALINITY_SENSOR" – Craig Mar 6 '12 at 20:01
Actually that 80 is the total_alkalinity_value for this response, but that can't be the right place for it. In the other examples I've seen the data value is within the "om:result" element – Craig Mar 6 '12 at 20:47
@craig It looks like it should be. I've update my answer - try running with the test data to check it works with postGIS. – geographika Mar 6 '12 at 22:52
In the example data you linked to the procedure element was giving the stn_id (station id) and nested in the om:Result was a ms:Value which is the data that I am trying to set. But thanks to the other sample files ( and obs.shp) I saw that changing my SQL to include the line "av.value::NUMERIC AS Value" gave me the output I wanted. Thanks for pointing me that way – Craig Mar 7 '12 at 3:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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