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.
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).
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.
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).
This will crash Pro and ArcMap/Catalog when it reaches a coverage. Changing to arcpy.da.Describe() for Pro doesn’t help.
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().
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.
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).