[gdal-dev] ogr2ogr - importing gml with more then one value for attribute

Even Rouault even.rouault at mines-paris.org
Thu Jul 3 15:34:26 PDT 2014


Le vendredi 04 juillet 2014 00:14:19, Piotr Pachół a écrit :
> Now I understand when I try to import from gml to PostGIS - everything
> is OK.
> But what I wanted to achieve is import from gml to FileGDB.
> I have warning: "Cannot map OGR field type (StringList)"
> So with GDB target format it is not possible ?

Only a few formats can support string lists. But you can try one of the 2 
following options of ogr2ogr :
-splitlistfields
-fieldTypeToString StringList

See http://gdal.org/ogr2ogr.html for their documentation.

> 
> Piotr
> 
> W dniu 2014-07-03 21:02, Even Rouault pisze:
> > Le jeudi 03 juillet 2014 15:35:57, Piotr Pachół a écrit :
> >> Hello,
> >> I have problem using ogr2ogr during import gml file which can have one
> >> or more then one value for an attribute e.g.:
> >> 
> >> <gml:featureMember>
> >> 
> >>      <id>101</id>
> >>      <fun>A</fun>
> >>      <fun>B</fun>
> >>      
> >>       .
> >>       .
> >> 
> >> </gml:featureMember>
> >> <gml:featureMember>
> >> 
> >>      <id>102</id>
> >>      <fun>C</fun>
> >>      
> >>       .
> >>       .
> >> 
> >> </gml:featureMember>
> >> 
> >> In above situation ogr2ogr didn't  import at all attribute "fun".
> > 
> > If you use a recent enough version of GDAL, it should work (generally) :
> > 
> > let's say I have poly.gml :
> > 
> > <?xml version="1.0" encoding="utf-8" ?>
> > <ogr:FeatureCollection
> > 
> >       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> >       xsi:schemaLocation="http://ogr.maptools.org/ poly.xsd"
> >       xmlns:ogr="http://ogr.maptools.org/"
> >       xmlns:gml="http://www.opengis.net/gml">
> >    
> >    <ogr:featureMember>
> >    
> >      <ogr:poly gml:id="poly.0">
> >      
> >        <ogr:foo>bar</ogr:foo>
> >        <ogr:foo>baz</ogr:foo>
> >      
> >      </ogr:poly>
> >    
> >    </ogr:featureMember>
> > 
> > </ogr:FeatureCollection>
> > 
> > $ ogrinfo poly.gml -al
> > Had to open data source read-only.
> > INFO: Open of `poly.gml'
> > 
> >        using driver `GML' successful.
> > 
> > Layer name: poly
> > Geometry: None
> > Feature Count: 1
> > Layer SRS WKT:
> > (unknown)
> > gml_id: String (0.0)
> > foo: StringList (0.0)
> > OGRFeature(poly):0
> > 
> >    gml_id (String) = poly.0
> >    foo (StringList) = (2:bar,baz)
> > 
> > It creates a field of StringList type.
> > 
> >> May be in this situation it would be better when user can choose one of
> >> variant:
> >> - import first encountered value of attribute "fun" from each record
> >> e.g.: "A",
> >> - import all values separated with comma e.g.: "A, B"
> >> - ideal solution but difficult: create auxiliary table which keeps all
> >> 
> >> relations one to many e.g.:
> >>       101  A
> >>       101  B
> >>       102  C
> >> 
> >> Regards,
> >> Piotr

-- 
Geospatial professional services
http://even.rouault.free.fr/services.html


More information about the gdal-dev mailing list