Select to view content in your preferred language

Change FeatureLayer's Datasource

478
2
Jump to solution
06-13-2022 08:33 PM
Lazyman
Occasional Contributor

Hi, I want to change the layers's datasource to geodatabase(gdb) instead of sqlite. If I do the operation "Set Data Source" in ArcCatalog  that it would make the ArcCatalog crash. I try to change the data source by ArcObjects or ArcPy, but it doesn't work, I can't figure out the solution. Can you help me, please!

Here's my python code

 

 

import arcpy.mapping as mapping
mxd = mapping.MapDocument(r"C:\XdApp\data\xd.mxd")
mxd.findAndReplaceWorkspacePaths(r"C:\XdApp\data\test.sqlite", r"C:\XdApp\data\test.gdb")
mxd.saveACopy(r"C:\XdApp\data\xd2.mxd")

 

 

 

0 Kudos
1 Solution

Accepted Solutions
GKmieliauskas
Esri Regular Contributor

Hi,

You are trying to change workspace type. findAndReplaceWorkspacePaths can't do that. You need to use replaceWorkspaces from MapDocument, or replaceDatasource from Layer. More info here:

https://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-mapping/updatingandfixingdatasources.htm 

View solution in original post

0 Kudos
2 Replies
GKmieliauskas
Esri Regular Contributor

Hi,

You are trying to change workspace type. findAndReplaceWorkspacePaths can't do that. You need to use replaceWorkspaces from MapDocument, or replaceDatasource from Layer. More info here:

https://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-mapping/updatingandfixingdatasources.htm 

0 Kudos
Lazyman
Occasional Contributor

Thank you, I really appreciate your help!

0 Kudos