I'm working on a project that would like to use spatialite as a go-between for field edits using QGIS/IntramapsRoam and then loading the data to a file geodatabase.

The workflow is as follows Spatialite (created in ArcGIS using 'SPATIALITE' geometry) -> QGIS -> ArcGIS 10.2

I'm running in to a compatibility issue with arcpy and spatialite that renders my workflow impossible and am wondering if this has been encountered before and if there are any known solutions/workarounds.

#Create the database
sqllite_database = r'.\test.sqlite'
arcpy.gp.CreateSQLiteDatabase(sqlite_database, “SPATIALITE”)
                                    'points', "POINT")
                          "num_field", "TEXT")

After creating the database, I can access it with arcpy.

enter image description here

I then add a point in QGIS and save edits.

enter image description here

I can no longer access the layer with arcpy.

enter image description here

Oddly enough, I can still access the table from ArcMap, but arcpy is the functionality that I really need.

Given the lack of informative error messages and documentation for arcpy with spatialite, does anyone know what might be causing this? Any suggestions for solutions or workarounds?

Update: Here is a screen showing the layer drawing in ArcMap and returning False in arcpy. This seems like errant behavior. enter image description here

Update 2: I tested again using ArcGIS10.3.1 and it still failed. Apparently you cannot edit sqlite databases in QGIS and retain arcpy functionality.

  • You might need to rebuild the spatial indices or a repair geometry? – crmackey Jan 8 '16 at 15:07
  • @crmackey I tried rebuilding the spatial index in ArcCatalog and got 'Failed to Delete Spatial Index. Invalid spatial column name. The field is not nullable'. I rebuilt it within the Spatialite-GUI and that didn't fix my issue. – KJYDavis Jan 11 '16 at 13:48
  • What do you mean by still access the table from ArcMap after using QGIS to modify it. Is ArcMap still open with the data loaded at the same time as your QGIS edit? It sounds odd you can 'see it, access it' in ArcMap, but not access it with arcpy. (Yeah Im inferring that if the QGIS edit did something Arc* doesn't like, it shouldn't work anywhere, not work in some) – KHibma Jan 11 '16 at 15:31
  • I create the database in Arcpy. Close everything. Open QGIS and add a point. Close everything. Try to access the data in arcpy, get the error above. Close everything. Open ArcMap and drag the layer into the map, it adds and I can view the data and attribute table. Interestingly, using Arcpy.Exists('.\test.sqlite\main.points') returns False. So it really does seems to be an arcpy specific thing. – KJYDavis Jan 11 '16 at 15:36
  • 1
    I just tried your workflow (everything accept the QGIS part) in ArcMap... and arcpy.Exist works in both 10.3.1 and 10.4. I think SQLLITE was introduced as an option in 10.2, so its possible there was a bug there thats since been fixed? Just a guess. – KHibma Jan 11 '16 at 18:25

Your Answer

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

Browse other questions tagged or ask your own question.