Improved documentation for updateConnectionProperties(): workspace_factory

5676
11
03-24-2023 11:50 AM
Status: Under Consideration
Labels (1)
AlfredBaldenweck
MVP Regular Contributor

Please see this post for more details.

For context, I've been trying to write some code to mass-replace data sources. However, Pro's only way to do this, updateConnectionProperties(), requires you to know not just the file path, but what type of file and workspace it belongs to. *

This would be fine except there's no documentation for acceptable values, nor is there an easy way to find out, short of loading all of your files and checking their connection properties yourself.

What I am looking for is an exhaustive list of possible values for the workspace_factory parameter

Here are places I have checked:

  1. Updating and fixing data sources—ArcGIS Pro | Documentation
  2. Layer—ArcGIS Pro | Documentation
  3. ArcGISProject—ArcGIS Pro | Documentation
  4. Describe object properties—ArcGIS Pro | Documentation
  5. Layer properties—ArcGIS Pro | Documentation
  6. Workspace properties—ArcGIS Pro | Documentation
  7. Parameter data types in a Python toolbox—ArcGIS Pro | Documentation
  8. WorkspaceFactory Class (ArcObjects .NET 10.8 SDK) (arcgis.com) (ArcMap)
  9. IWorkspaceFactory Interface | ArcGIS Enterprise SDK (Pro)
  10. layer.replaceDataSource() (ArcMap)
  11. Just about every python file in the arcpy folder.

At the end of all of this, I still don't have any idea of what my possible options are.

Improved documentation would be a lifesaver, considering updateConnectionProperties() already asks you do a lot of the thinking that it should be doing for you (Meaning it should be able to figure out if you’re feeding it a shapefile or not without you telling it).

Please update the documentation somewhere, be it at Updating and fixing data sources—ArcGIS Pro |  Documentation or Layer—ArcGIS Pro | Documentation and ArcGISProject—ArcGIS Pro | Documentation

Detailed documentation of my search:

Spoiler

1. Updating and fixing data sources—ArcGIS Pro | Documentation only gives the example of “File Geodatabase”, but it is far from exhaustive.

2. Layer—ArcGIS Pro | Documentation Looking at the connectionProperties, didn’t go anywhere, due to the lack of a comprehensive list.

AlfredBaldenweck_0-1679683024396.png


3. ArcGISProject—ArcGIS Pro | Documentation See #2, Layer

4. Describe object properties—ArcGIS Pro | Documentation Nothing helpful in the basic properties, but put me onto Layer Properties (Describe).

5. 
Layer properties—ArcGIS Pro | Documentation I checked dataElementType and dataType. Neither are formatted correctly, so I would need to build a dictionary to match to the (missing) comprehensive list.

AlfredBaldenweck_1-1679683024398.png

I thought I might be able to make a list by just describing every file in a directory, then returning the set, but surprise: any coverages will crash both Pro and ArcMap (To be clear, I'm not planning on using coverages, but we do have some and they're getting in the way of trying to get this list).

AlfredBaldenweck_2-1679683024399.png

This will crash Pro and ArcMap/Catalog when it reaches a coverage. Changing to arcpy.da.Describe() for Pro doesn’t help.

6. Workspace properties—ArcGIS Pro | Documentation has a very small list of possible properties:

  • esriDataSourcesGDB.AccessWorkspaceFactory.1—Personal geodatabase
  • esriDataSourcesGDB.FileGDBWorkspaceFactory.1—File geodatabase
  • esriDataSourcesGDB.InMemoryWorkspaceFactory.1—In-memory workspace
  • esriDataSourcesGDB.MemoryWorkspaceFactory.1—Memory workspace
  • esriDataSourcesGDB.SdeWorkspaceFactory.1—Enterprise geodatabase
  • esriDataSourcesGDB.SqliteWorkspaceFactory.1—Mobile geodatabase
  • (empty string)—Other

This list is not exhaustive; shapefiles and rasters would not return anything useful, despite having an entry in connectionProperties. Also, this list is not formatted in the way I need for use in updateConnectionProperties().


7. Parameter data types in a Python toolbox—ArcGIS Pro | Documentation See #4, Layer Properties, dataElementType

8. WorkspaceFactory Class (ArcObjects .NET 10.8 SDK) (arcgis.com) (ArcMap) provides a list but not with correct formatting.

9. 
IWorkspaceFactory Interface | ArcGIS Enterprise SDK (Pro) provides a list but not with correct formatting.

10. replaceDataSource() (Arcmap) has a potentially useful list, although not formatted in a helpful way.

  • ACCESS_WORKSPACE — A personal geodatabase or Access workspace
  • ARCINFO_WORKSPACE — An ArcInfo coverage workspace
  • CAD_WORKSPACE —A CAD file workspace
  • EXCEL_WORKSPACE —An Excel file workspace
  • FILEGDB_WORKSPACE —A file geodatabase workspace
  • NONE —Used to skip the parameter
  • OLEDB_WORKSPACE —An OLE database workspace
  • PCCOVERAGE_WORKSPACE —A PC ARC/INFO Coverage workspace
  • RASTER_WORKSPACE —A raster workspace
  • SDE_WORKSPACE —An SDE geodatabase workspace
  • SHAPEFILE_WORKSPACE —A shapefile workspace
  • TEXT_WORKSPACE —A text file workspace
  • TIN_WORKSPACE —A TIN workspace
  • VPF_WORKSPACE —A VPF workspace

11. I checked _mp, arcobjects (every file), anything to do with toolboxes. Nothing.

*To be clear, depending on your use case, you may need less. In my case, where I'm frequently changing not just the GDB or folder, but also changing to a file with a different name, I do need this information. See "Changing a layer's dataset" here.

11 Comments
CSDING_GIS

I also believe this would be a very important enhancement.

For a python toolbox I'm building, certain scripts need to consume .lyrx files distributed within the python package for the interactive feature parameter. The data connection posed an issue, since they referenced a FGDB on my machine, but at the same time, I don't want to create a feature class upon opening the tool just to load the .lyrx correctly.

Finally I was able to solve it by changing the data source connection to "InMemoryDB". I found out that the correct workspaceConnectionString for such case is "INSTANCE_ID=GPProMemoryWorkspace". This isn't documented anywhere. (Though it wasn't hard to find out, I just created a FC in memory and checked the lyrx' JSON).