Determining Workspace Type (ArcMap)

993
5
02-14-2023 12:32 PM
AlfredBaldenweck
MVP Regular Contributor

Hi all, 

I'm trying to mass replace datasources. I have my dictionary, I have my general workflow, and initial testing is working fine on the test files I'm using, all of which are feature classes in file gdbs. I'd like to expand it to other file types.

Where I'm running into trouble is using arcpy.mapping.replaceDataSource() , specifically the workspace type parameter.

It seems that arcpy can't figure out the workspace type by itself, so we have to provide it.

  • 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

I thought that I could use arcpy.Describe on the workspace, but that is less than ideal :

  • FileSystem —File-based (coverage, shapefile, and so forth) workspaces and in-memory workspaces
  • LocalDatabase —Geodatabases that are local (a file or personal geodatabase)
  • RemoteDatabase —Geodatabases that require a remote connection (enterprise, OLE DB, and so forth)

As you can see, that gives me a very vague idea of what I'm working with.

I also thought that maybe I could Describe() on the new data sources themselves, but for example, a coverage just says "Coverage", rather than the coverage type.

Is there an easy way to determine workspace type?

 

Thanks!

Tags (2)
0 Kudos
5 Replies
AlfredBaldenweck
MVP Regular Contributor

As an update to this, I solved my original question by just brute-forcing it. I run through a loop of possible workspace types until it works.

0 Kudos
DuncanHornby
MVP Notable Contributor

If you look at the helpfile on describing a workspace it shows how to get finer granularity with workspace types using the property workspaceFactoryProgID.

0 Kudos
AlfredBaldenweck
MVP Regular Contributor

Thanks for the response.

I've looked at that property as well, but it doesn't actually give me what I'm looking for.

For example, that would return an empty string for things like Shapefiles, or even standalone rasters. 

It wasn't a big deal for ArcMap, but as I turn my attention to Pro with the absolutely awful updateConnectionProperties(), changing datasets requires you to know the workspace type.

Just testing so far, there are at least two types of workspace factory that are unaccounted for.

AlfredBaldenweck_1-1679587133558.png

Is there a full list of potential types floating around somewhere?

 

0 Kudos
DuncanHornby
MVP Notable Contributor

Sounds like your research into the issue is good evidence for an ESRI Idea, to improve the list of identifiable workspace types?

AlfredBaldenweck
MVP Regular Contributor
0 Kudos