[gdal-dev] [python-ogr] GML attributes are missing
Frank Broniewski
brfr at metrico.lu
Fri Feb 25 04:34:38 EST 2011
Hello,
I have a problem when converting datasources from one format to GML.
Whenever I export my source datasource to a GML - datasource the
attributes of the features are missing in the resulting gml file. Other
exports to formats like shapefile, kml or geojson have the attributes
included. When I use ogr2ogr the gml has attributes included. So my
question is: What's the difference between e.g. a kml and a gml
outputformat and why does one have attributes and the other doesn't?
I tried on windows using gdal 1.8 and on Hardy 8.04 with 1.7.x, and on
both there're no attributes with the gml.
I use the following code to transform from one format to another:
target_driver = driver_by_name(target_format_name)
target_datasource = create_datasource(target_driver, output_destination)
for layer in iterate_layers(source_datasource):
layer_name = layer.GetName()
geometry_type = get_geometry_type(layer)
target_layer = target_datasource.CreateLayer(layer_name, source_srs,
geometry_type)
feature_definition = layer.GetLayerDefn()
for feature in iterate_features(layer):
target_feature = ogr.Feature(feature_definition)
target_feature.SetFrom(feature)
target_feature.SetFID(feature.GetFID())
if transformation is not None:
geometry_reference = feature.GetGeometryRef()
geometry = geometry_reference.Clone()
geometry.Transform(transformation)
target_feature.SetGeometryDirectly(geometry)
target_layer.CreateFeature(target_feature)
Full code:
http://paste.pocoo.org/show/344283/
Python test file
http://paste.pocoo.org/show/344284/
Frank
--
Frank BRONIEWSKI
METRICO s.à r.l.
géomètres
technologies d'information géographique
rue des Romains 36
L-5433 NIEDERDONVEN
tél.: +352 26 74 94 - 28
fax.: +352 26 74 94 99
http://www.metrico.lu
More information about the gdal-dev
mailing list