ArcGIS 10.1

Update the data source in an ArcMap project using python, arcpy.mapping

Need to update a path in your ArcMap project to reflect the new location?  Here's how...

There are several methods for updating data sources using arcpy.mapping, check out this help topic from ESRI.  The example listed below is just one of several methods.

 Attach the following python code to a script in the toolbox of the mxd you wish to update.  This will allow you to update the directory the data layer is referencing, but will NOT allow you to change the data layer source name itself.  To change the data layer source name use the 'replaceDataSource' method instead.


import arcpy
mapdoc = arcpy.mapping.MapDocument("CURRENT")
mapdoc.findAndReplaceWorkspacePaths("<the directory you are changing from>" , "<the directory you are changing to>")
del mapdoc


TIPS / Notes:

--You could get fancy and set the 'directory you are changing from' and the 'directory you are changing to' to input arguments.  Then, the script could be used for resetting any project.

--If you don't know the directories your data are referencing you can insert print lyr.dataSource.  This will  return a list of data sources used in the mxd.

--If you know you have broken links in your mxd, here's how to get a list printed to the python shell window.

import arcpy
mapdoc = arcpy.mapping.MapDocument("CURRENT")
brokenlist = arcpy.mapping.ListBrokenDataSources(mapdoc)

      for lyr in brokenlist:      


del mapdoc



ArcGIS 10.x tip! Overwrite previous outputs from geoprocessing

Do you need to geoprocess the same file again and again.  If only you could simply overwrite the old output file!  Do you end up with files like 'Clip', 'Clip1', 'Clip2'...when you only really need one file named 'Clip'?  Well, here's how to remedy all the duplicate files.  You can set up the Geoprocessing options to overwrite previous outputs.    

NOTE!  If you are person that likes all these copies, I don't recomend setting up the overwrite option.  You may accidentally lose data by overwriting a previous version.  Use this with caution, but be prepared for cleaner GIS directories.

On the menu bar click, Geoprocessing and Geoprocessing options-

An options box will appear.  Simply CHECK the 'Overwrite the outputs of the geoprocessing operations' and OK.  You can now geoprocess files and overwrite previous versions under the same name!  (Be sure to check out some of the other options - you might find something else really useful.)


ArcGIS 10.1 TIP: Setting Projections as 'Favorites' in ArcGIS 10.1 - *NEW* in 10.1

New in 10.1!

Tired of scrolling through all the possible projections when you only use about 3 or 4 of them?  In ArcGIS 10.1 you can now save commonly used projections as a ‘favorite’.

Next time you are specifing a projection for a dataset you can mark the projection as a 'favorite' by simply clicking the 'star icon' in the top right corner of the dialog box.

Next time you need to specify that projection, simply look for it within the 'favorites' section.