[gdal-dev] featureCollection within a featureCollection

skyking skyking at ilikecarrots.com
Sun Aug 30 19:59:06 PDT 2020


Hello,

I'm having trouble parsing some GML via Python/ogr and would like some 
advice.

The GML has as the top level a FeatureCollection which has 3 
featureMembers.  However, each of those featureMembers contains a 
FeatureCollection within it containing any number of featureMembers.

While parsing, each of the featureMembers has a dict of elements, and 
the values of that featureMembers' keys is a list of the values of each 
of the "sub-featureMember"s attributes.  That's good so far, but I'm not 
able to retrieve the geometry for the sub-featureMembers.

How do I use Python ogr to parse a FeatureCollection within a 
FeatureCollection?  Does a ResetReading() somehow reset something so 
that the inner members get processed correctly?

Thank you,
Wendell

A sample of the nested xml components:

<?xml version="1.0" encoding="utf-8"?>
<wx:FeatureCollection gml:id="id0" ...>

  <wx:featureMember>
   <wx:Forecast gml:id="id1">

    <om:result>
     <wx:FeatureCollection gml:id="id5">

      <wx:featureMember>
       <wx:Contour gml:id="id6">
        <wx:geometry>
            ...
        </wx:geometry>
       </wx:Contour>
      </wx:featureMember>

      <wx:featureMember>
       <wx:Contour gml:id="id10">
        <wx:geometry>
            ...
        </wx:geometry>
       </wx:Contour>
      </wx:featureMember>

     </wx:FeatureCollection>
    </om:result>
   </wx:Forecast>
  </wx:featureMember>

  <wx:featureMember>
   <wx:Forecast gml:id="id1438">
    <om:result>
     <wx:FeatureCollection gml:id="id1442">
      <wx:featureMember>
          ...


More information about the gdal-dev mailing list