1

I am exporting data from PostGIS to gml using python script with ogr2ogr. But the output generates unwanted new field "fid" that contains the following string: "sql_statement.0" , "sql_statement.1", ... and so on. Is there a way to prevent this? I already have a field with unique feature identifiers. enter image description here

cmd = ogr2ogr + " -f  \"GML\" " + filename + " PG:" + db_connect + " -sql " + query
  • 1
    alias your PK column AS fid: ogr2ogr wants that identifier for GML, and it seems the driver will add that field in any case. – geozelot Jan 24 '20 at 23:10
  • Thanks, that did exactly what I needed. :) – ousekmatej Jan 27 '20 at 8:22
  • Could you write that as an answer? – user30184 Jan 30 '20 at 9:54
1

From @ThingumaBob comment:

alias your PK column AS fid: ogr2ogr wants that identifier for GML, and it seems the driver will add that field in any case.

Aliasing the collumn I wanted as fid worked and no new attribute field was created when exporting to gml.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.