[gdal-dev] Python ogr GetFieldAsString problem
    Steve.Toutant at inspq.qc.ca 
    Steve.Toutant at inspq.qc.ca
       
    Wed May 13 12:11:21 PDT 2015
    
    
  
I'm trying to parse a GML and read all the values of an attribute.
Example
<gml:featureMember> 
      <ms:SMDVDP_STAT_METE fid="SMDVDP_STAT_METE.2153"> 
        <ms:LONG_STAT>-64,2131</ms:LONG_STAT> 
      </ms:SMDVDP_STAT_METE> 
    </gml:featureMember> 
DescribeFeatureType for this layer returns 
<element name="LONG_STAT" minOccurs="0" type="double"/> 
wfs_ds = ogr.Open(tmp_file.name)  #tmp_file.name is the response of a WFS 
getFeature request
layer = wfs_ds.GetLayerByName('SMDVDP_STAT_METE ')
feat = layer.GetNextFeature()
      while feat is not None:
          output.add(feat.GetFieldAsString('LONG_STAT'))
          feat = layer.GetNextFeature()
(At runtime, the WFs, layer and attribute can be anything of any type. And 
decimal separator, can be ',' or '.')
The problem is that feat.GetFieldAsString('LONG_STAT') truncate the string 
to the comma
So instead of having -64,2131, I get -64 in the output
What is the appropriate way to get the value of an attribute?
thanks you!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20150513/1bcfba6c/attachment.html>
    
    
More information about the gdal-dev
mailing list