Wednesday, 13 July 2016

Unable to update features in tables without FID: How to use gid field as the FID column with ogr/gdal python?


I'm trying to update a PostGIS table using the SetField() method in python. The table is imported from a shapefile with pgsql2shp so it has a gid field, which can be used as FID or primary key.


However, when executing SetField(), I get an error saying:


Error 1: Unable to update features in tables without a recognised FID column. 


I tried different things. The only thing that allows updating is to externally add and populate a new column called ogc_fid. Even adding a 'fid' column won't do.


Is there a way to tell ogr/gdal (as of gdal2.1.3) in the python code itself that an existing field such as gid is the FID column?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...