1

My question is somehow related with my previous one Failed to insert data to geoserver layer with WFS-T. I use python and requests in order to create a new feature in a geoserver layer. I have managed to make a successful request and add the geometry of the feature to the layer.

Now I am trying to make the same post request but also to include other values of attributes that they exist in the layer.

What is the format in order to achieve something like this? As far as I see, the Demo page of geoserver doesn't provide an example like this.

@iant helped me figure this out. This is how my xml looks like:

<wfs:Transaction service="WFS" version="1.1.0"
  xmlns:wfs="http://www.opengis.net/wfs"
  xmlns:gml="http://www.opengis.net/gml">
  <wfs:Insert>
   <bgd_uti_transmissionline_nrel>
     <the_geom>
      <gml:MultiLineString srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
      <gml:lineStringMember>
       <gml:LineString>
        <gml:coordinates decimal="." cs="," ts=" ">
        39.247354197,21.438097723 89.247354197,18.438097723
        </gml:coordinates>
      </gml:LineString>
     </gml:lineStringMember>
    </gml:MultiLineString>
   </the_geom>
   <CODE>5</CODE>
   <POWERLIN_I>1</POWERLIN_I>
   <OBJECTID>2</OBJECTID> 
   <GLOBALID>fd</GLOBALID> 
  </bgd_uti_transmissionline_nrel>
 </wfs:Insert>
</wfs:Transaction>
  • Not the most elegant solution but maybe using Wireshark to monitor a WFS-T update from QGIS and reverse engineer? – nielsgerrits Jul 22 '16 at 10:41
5

The best place to look for details like this is in the standard.

Inserting non spatial attributes is done in exactly the same way as adding spatial attributes. First check the schema of the feature type by using a describeFeature request, then construct a Transaction request with the attribute values in the same order as the schema requires.

  • Thanks @iant. This works. But is it really the case that I need to provide the parameters in the exact order they are described in the describeFeature request? What I am building will be automated and will add an overhead if I need to retrieve the order of the attributes. – user1919 Jul 22 '16 at 11:46
  • That's how xml works I'm afraid. – Ian Turton Jul 22 '16 at 11:50
  • if you want you can check my edited answer. I made it work and although I don't follow the order shown in the describeFeature, still the values are updated correctly! :) – user1919 Jul 22 '16 at 11:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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