I am using OS Translator tool to convert OSMasterMap GZ files to PostgreSQL database. The feature classes created are query layers and cannot be edited in ArcGIS. Now I am writing a code to add new data to the existing feature classes. For this purpose, I am deleting the old rows in the given extent of new data and inserting the new data. However, I am getting an error "Create cursor failed" while deleting and I haven't even tried Inserting.

What I have done as an alternative workaround is that :

  1. I created shapefiles of the OS Master Map feature classes locally.

  2. Then I created new feature classes in PostgreSQL with similar fields which is for some reason editable.

  3. I am then trying to insert the data from shapefile to this new editable feature class.

After this I am able to update and insert data on the new feature class when new data comes.

Please can you tell me if I can directly update and insert the feature classes created by OS Translator so that I can skip these steps in the middle.

Here is my code:

import arcpy
import datetime

temp_workspace = arcpy.GetParameterAsText(0)
sde_workspace = arcpy.GetParameterAsText(1)
arcpy.env.workspace = sde_workspace


  #Converting Feature Classes to Shapefiles in Temporary workspace
        arcpy.FeatureClassToShapefile_conversion(["postgretest.postgres.boundaryline","postgretest.postgres.cartographicsymbol","postgretest.postgres.cartographictext", "postgretest.postgres.topographicarea", "postgretest.postgres.topographicline","postgretest.postgres.topographicpoint"], temp_workspace)

#Looping through each shapefile and updating the features in featuredataset in enterprise geodatabase
arcpy.env.workspace = temp_workspace
fcList = arcpy.ListFeatureClasses()

for fc in fcList:

    #Boundary Line............................................................................
    if(fc == "boundaryline.shp"):
        fc1 = fc
        fc2 = sde_workspace + "\postgretest.postgres.boundary_line"

        print "Starting for Boundary Line..."

        #set up cursor for adding features
        inscursor = arcpy.da.InsertCursor(fc2,["postgretest.postgres.boundary_line.fid","FEATURECODE","VERSION","versiondate","accuracyofposition","make","physicallevel","physicalpresence","style_description","style_code","SHAPE@"])
        with arcpy.da.SearchCursor(fc1,["fid_","featurecod","version","versiondat","accuracyof","make","physicalle","physicalpr","style_desc","style_code","SHAPE@"]) as innercursor:
            for searchrow in innercursor:
                geom = searchrow[10]
                row_values = [searchrow[0], int(searchrow[1]),int(searchrow[2]), searchrow[3],int(searchrow[4]),int(searchrow[5]),int(searchrow[6]),searchrow[7],searchrow[8], int(searchrow[9]),geom]


Source Table: "wkb_geometry" - Geometry "fid" - Text Length = 0 "featurecode" - Long Numeric "version" - Long Numeric "versiondate" - Text Length = 0 "accuracyofposition" - Text "make" - Text "physicallevel" Numeric Long "physicalpresence" - Text "style_description" - Text "style_code" - Nummeric Long

  • A description of the as-built tables would be far more useful than work-around code. ArcGIS doesn't support BIGINT datatypes, so if the tables contain one, that's your issue.
    – Vince
    Commented May 23, 2016 at 11:44
  • Hi Vince, I am not too confident if there is a BIGINT column because there were some columns added while converting the gz files which gave an error invalid column upon adding in Arcmap and I have removed those columns now while converting to featureclass and still the layer is not editable. Please can you elaborate a little bit on the as-built table approach. Commented May 23, 2016 at 14:12
  • I have found a field style_description which is of length 1073741822. Could this be the cause??? Commented May 23, 2016 at 14:15
  • As-built isn't an approach, so it can't be elaborated. You need to describe the source table in the question so that your cursor issue can be understood. There is nothing wrong with having a CLOB column in a table. Looking at your code, it appears you're playing fast and loose with login/user/schema (and using postgres -- a HUGE security no-no) which could mess up any write access
    – Vince
    Commented May 23, 2016 at 14:28
  • Hi Vince, sure I will keep in mind to have a new user and a new schema. This is a test scenario where the final aim is to maintain the National Master Map database. Commented May 23, 2016 at 14:32


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.