Select to view content in your preferred language

Add Data

690
3
11-19-2009 07:03 AM
TedCronin
MVP Alum
This would be useful to help automate data updates between different mxds, and other formats (3dd, and sxd), so would be nice to have the capability in arcpy to add data.  Selections that need to be used in other applications, copy data here after I work on it there, all in py.  This would be cool.
0 Kudos
3 Replies
JasonScheirer
Esri Alum
Not entirely sure what you mean. Right now there is a workflow that might work for you to add data to an MXD:


  • Save out a layer file with the desired symbology, with any data source

  • Use arcpy.mapping.Layer(filename) object to get a handle to it in Python

  • Change the layer.dataSource property to your new data source (make sure it's the same feature type as the saved layer; point/poly/etc)

  • Use arcpy.mapping.AddLayer to add the edited layer to the desired dataframe


There is also the arcpy.mapping.UpdateDataSources function which has bulk data source updating capability on map documents.
0 Kudos
TedCronin
MVP Alum
Not entirely sure what you mean. Right now there is a workflow that might work for you to add data to an MXD:


  • Save out a layer file with the desired symbology, with any data source

  • Use arcpy.mapping.Layer(filename) object to get a handle to it in Python

  • Change the layer.dataSource property to your new data source (make sure it's the same feature type as the saved layer; point/poly/etc)

  • Use arcpy.mapping.AddLayer to add the edited layer to the desired dataframe


There is also the arcpy.mapping.UpdateDataSources function which has bulk data source updating capability on map documents.


I will play with this, I think the AddLayer may work for us, so will play with it, thank you Jason.  I haven't entered the Mapping package, officially yet.  I was trying to setup a test database for Scene, which I am doing in Map, the addLayer would be handy for populating a sxd after I do selections in Map, so will tinker.

Based on Name Add Layer denotes a feature layer rather than a feature class, though.
0 Kudos
MikeLouwrens
Frequent Contributor
There is also the arcpy.mapping.UpdateDataSources function which has bulk data source updating capability on map documents.
Does this function work?  I tried using this, it returns successfully creating a new MXD, but nothing changes in the document.
0 Kudos