How to change XY Event DataSource

4420
2
09-10-2014 04:05 PM
Lars_HolmThomsen
New Contributor II

Hi

 

Im trying to use ArcPy to make a change, that is just not a success!

 

In a mxd I have a table (table1) i a file-geodatabase - GDB1 (origin: Excel-sheet). The table contains some georeferenced data that is shown as an XY Event layer too. So I have two items addressing the same data - a standalone table (not shown in ListByDrawingOrder-mode) and a XY Event layer that has some symbology.

 

In TOC I can dbl-click them both and set a new datasource for both - individually! The problem is to do it by code (arcpy).

 

I have transfered the data to an other file-geodatabase (GDB2) and therefore I would like to change/replace the datasource for both items to the new GDB2-location.

 

I have created a script that changes the standalone table datasource to the new one (Path2\GDB2.gdb\Table2) but the corresponding XY Event still uses the old Datasource (Path1\GDB1.gdb\Table1).

The ArcPy metode used involves "for atable in arcpy.mapping.ListTableViews(mxd)" and then replacing datasource by "atable.replaceDataSource(NewGdb,"FILEGDB_WORKSPACE",NewName,True) " - but I cant find any references to the XY Event.

 

How do I change the XY Event DataSource to the new GDB and name - using ArcPy???? It is not an issue doing it manually i ArcGis/ArcCatalog, so please dont suggest this. It HAS to be done by code!

0 Kudos
2 Replies
MichaelStead
Occasional Contributor III

with a broken source event them I am able to change the data source of the "layer"...not the table... and this change shows up in ArcCatalog under the datasources table thing.... the layer remains unlinked though. I suspect something different with the way the dataSource parameter is being associated with event layers. Reasonably sure this can't be addressed with python and replacedatasource/workspace workflows...

0 Kudos
MichaelStead
Occasional Contributor III

I finally figured out as close as I can to a "solution" for this issue. I created a script that iterates througn mxds in a folder exporting event themes to point features and then run a repathing script from the event layer to the point layer. This seems to work, although if you go to the layers properties after updating the source, the Source tab in the layer properties is completely blank, but the source checks out using arcpy or in Catalog. As there is zero documetation for any of this, I would add that this is at your own risk, but does seem to work if you are not restricted to relinking to a new table source.

0 Kudos