[gdal-dev] feature.clone() -> same featuredefn

Even Rouault even.rouault at mines-paris.org
Mon Aug 4 04:56:55 PDT 2014


Le lundi 04 août 2014 12:46:22, Martin Landa a écrit :
> Hi Even,
> 
> 2014-08-02 22:18 GMT+02:00 Even Rouault <even.rouault at mines-paris.org>:
> 
> [...]
> 
> > You can use the SetFrom() method.
> 
> it solved my problem, but it doesn't seems to copy geometry columns...
> 
> """
>             ofeature = ogr.Feature(olayer.GetLayerDefn())
>             ofeature.SetFrom(feature)
>             print feature.GetDefnRef().GetGeomFieldCount(),
> feature.GetDefnRef().GetFieldCount()
>             print ofeature.GetDefnRef().GetGeomFieldCount(),
> ofeature.GetDefnRef().GetFieldCount()
> """
> 
> 2 31
> 0 31          <-- 0!!!

Perhaps check that the line 
olayer.CreateGeomField(feat_defn.GetGeomFieldDefn(i)) is executed and its 
return code is 0.

Also, when running CreateLayer() with geom_type != wkbNone, this will create a 
default geometry field, which might get recreated again in your geometry field 
creation loop. But it does not look like like it is the case in your 
situation.

> 
> Martin

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


More information about the gdal-dev mailing list