3

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
3
  • 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
    Commented Jan 24, 2020 at 23:10
  • Thanks, that did exactly what I needed. :)
    – ousekmatej
    Commented Jan 27, 2020 at 8:22
  • Could you write that as an answer?
    – user30184
    Commented Jan 30, 2020 at 9:54

1 Answer 1

3

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 and acknowledge you have read our privacy policy.

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