We are in the middle of our ArcGIS 9.3 to 10.1 migration project and we have a lot of custom map documents (from different users) that among others, point to our current 9.3 SDE database. After our migration, we'll disable this database to the users so they can't connect anymore. That means they'll end up with broken links in their MXDs (that's basically what we want) and need to repoint to the new SDE.  I prepared a little script that should automatically repoint all broken layers to our new 10.1 SDE (using a connection file), but unfortunately I always run into the same error. I already checked out some other posts on this site (e.g.  and  ), but also on the ESRI forums e.g.  and the ESRI resource center of course. Also tried to repoint to e.g. a file geodatabase, but I'm getting the same error.  However, none of the suggestions apply to my case or worked for me, and after playing around almost the whole day now, I thought maybe someone here knows a solution to that problem. The code itself works fine, it finds the MXDs, spits out the broken layers if I ask it to, it's just the actual repointing command(s) that give me a headache..  Below my (simplified) code and the error I get. Thankful for any tips!  # Import system modules import sys, string, os, arcpy, datetime, shutil  # source folder(s) to look for MXDs sourcePath = r"D:\scripts\fixBrokenLinks\test" # new 10.1 SDE connection sde = r"\\path to *.sde connection file  # loop through folders and find all MXDs (put into a list) for root, dirs, files in os.walk(sourcePath):     for f in files:         if f.endswith(".mxd"):             mxdPath = root + "\\" + f             mxd = arcpy.mapping.MapDocument(mxdPath)             print "converting " + str(mxdPath)             brknList = arcpy.mapping.ListBrokenDataSources(mxd)             for brknItem in brknList: ##                print brknItem                 brknItem.replaceDataSource(sde, "SDE_WORKSPACE")#, brknItem, True)  ##                # ALTERNATIVE: ##                find_workspace = brknItem.dataSource ##                replace_workspace_path = r"\\path to *.sde connection file ##                print "find_workspace " + str(find_workspace) ##                brknItem.findAndReplaceWorkspacePath(find_workspace, replace_workspace_path)              newMXD = mxdPath[:-4] + "_NEW.mxd"             mxd.saveACopy(newMXD)             del mxd   And here the error I get:  Traceback (most recent call last):   File "D:\scripts\fixBrokenLinks\fixBrokenLinks_simple.py", line 19, in &lt;module&gt;     brknItem.replaceDataSource(sde, "SDE_WORKSPACE")#, brknItem, True)   File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\utils.py", line 181, in fn_     return fn(*args, **kw)   File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\_mapping.py", line 680, in replaceDataSource     return convertArcObjectToPythonObject(self._arc_object.replaceDataSource(*gp_fixargs((workspace_path, workspace_type, dataset_name, validate), True))) ValueError: Layer: Unexpected error   I'm using ArcGIS 10.1 SP1 (Build 3143) and Python 2.7.2
122639
Using the mxd.findAndReplaceWorkspacePaths method, if and MXD is updated and the path the the .sde connection file moves again all of the data sources will break again.   Is there a method to permanently update each SDE layer in an MXD Table of Contents to permanently store the SDE Server and Service? Ie. Just replace the SERVER and INSTANCE for each SDE layer in an MXD using python or ArcObjects in Pyhton?
92691
I'm trying to reproject, move from tab to shp and rename all the .tab contained in a folder tree using ogr2ogr.  I'm working with Windows 7, QGIS 1.8 installed with advanced OsGeo4w and gdal 1.9.2. I have no experience in batch.  Here's the code :  for /R %%f IN ('D:\3.BATCH\FAUNE\*.tab') do C:\Users\Samy\Desktop\SIGMA\15.webmapping\ms4w\tools\gdal-ogr\ogr2ogr.exe -s_srs EPSG:3727 -t_srs EPSG:2975 %%f "ESRI Shapefile" %%f_2975.shp %%f pause   By calling this .bat into the cmd line, nothing append. When I simplify the code, I have in the best case "Unable to open" as Nik posted in the 3rd ressource below.  I wrote this code with the following questions:        According to resource 1, I translate the -f "MapInfo File" "%~dpnf.tab" "%f" into %%f "ESRI Shapefile" %%f_2975.shp %%f because as it is shape, I can't use dpnf.  According to resource 2, I wrote -s_srs EPSG:3727 -t_srs EPSG:2975 to reproject.  Finally I checked that the "Hide extensions for known file types" was off, according to ressource 3.  I don't know what to do now. There seems to be so many different ways to write this one line of code.
68501
The only thing I need is an exact copy of an existing shapefile in the same directory with a different name.  I have tried:   arcpy.CopyFeatures_management (ORLinks, MyLinks) #ORLinks: old links, MyLinks: new links   but for some reason, I cant make it a feature layer using:  arcpy.MakeFeatureLayer_management(MyLinks, 'MyLinks')   Error Encountered:  Error: Failed to execute. Parameters are not valid. ERROR 000732: Input Features: Dataset  M:\RAIL\Rail2.0.shp does not exist or is not supported Failed to execute (MakeFeatureLayer).
76620
I'm working on Arcgis 10.  I have a point shapefile representing events with several points having coinciding coordinates (They have the same coordinates). For representing them in a dynamic way, I found a nice way - .  Problem is: I was asked to produce a static (paper) map of the events. Is there a tool that can take these events and shift them apart a bit so all will be seen?  (I know that spreading them about will alter their coordinates, but I am prepared to do so on a duplicate shapefile for the display on the map).
115637
What would be a few common events that could cause an .mxd to become corrupt? I have a few docs that eventually crash on me and the best solution is to continuously use the MXD doctor to fix the MXD.
97478
It seems like everyday I go to publish a service or connect to my SDE I get messages that I can't connect. It is particularly annoying when trying to publish a service to ArcServer. The connections are made, but for some reason they are timing out or becoming temporarily disconnected for whatever reason (Red X over the connection icons).  The fix is simple: As soon as I open Catalog and then double click on the connection, it re establishes connection and then I can do what I need in ArcMap. However, ideally I would like to stop this behavior.  Any ideas why this is happening? Can't find much in the help and it has been mentioned by several users in my organization.
68619
Currently I have to manually remove the /error?aspxerrorpath= part from the address to try again. And right now a lot of Oopses happen!
12452
I am trying to automate various tasks in ArcGIS Desktop (using ArcMap generally) with Python, and I keep needing a way to add a shapefile to the current map. (And then do stuff to it, but that's another story).  The best I can do so far is to add a layer file to the current map, using the following ("addLayer" is a layer file object):  def AddLayerFromLayerFile(addLayer):  import arcpy  mxd = arcpy.mapping.MapDocument("CURRENT")  df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]  arcpy.mapping.AddLayer(df, addLayer, "AUTO_ARRANGE")  arcpy.RefreshActiveView()  arcpy.RefreshTOC()  del mxd, df, addLayer   However, my raw data is always going be shapefiles, so I need to be able to open them. (Equivalently: convert a shapefile to a layer file without opening it, but I'd prefer not to do that).
63333
My code will not project and store the feature layer in the scratch.gdb. "ERROR 999999 ... The table name is invalid. The table was not found. [17_5330_51961Lake]"  The interpreter doesn't like "-" characters or beginning or ending in a number. Does anyone know of a work around?  import arcpy import os  mxd = arcpy.mapping.MapDocument("Current") mxdpath = mxd.filePath (filepath, filename) = os.path.split(mxdpath) MCP_Path = str(filepath)  srl = os.path.join(MCP_Path, r"CoordinateSystems\NAD 1983 UTM Zone 17N.prj")  WBYLID = "17-5330-51961"  WBYLIDlabel = WBYLID.replace("-","_")  LakeOut = os.path.join(MCP_Path + "\OutputData\Scratch.gdb", WBYLIDlabel + "Lake") arcpy.Project_management(fl, LakeOut, srl)
68486
I am trying to uninstall ArcGIS 10.3.1 for Desktop from Windows 7 SP1 using Uninstall a program and I am receiving an error message (pictured below):     Error 1325. EsriPyFldr is not a valid short file name.   The error message dialog appears just after:     Computing space requirements   seems to complete.  If anyone else has encountered this, then have you been able to find a way to get past it and uninstall ArcGIS 10.3.1 for Desktop?  My machine has what I would call a vanilla install of ArcGIS 10.3.1 for Desktop and ArcGIS Pro 1.1.1 so there are Python versions 2.7.8 and 3.4.1 as a result. ArcGIS Earth Beta is also on the machine.     I have made a posting on the same issue to   After running this utility () unsuccessfully (it hung for two hours before I killed it) the error message when trying to uninstall shifted to:     This action is only valid for products that are currently installed     ArcMap 10.3.1 continues to start fine and doing  wmic product where "Vendor like '%Environmental Systems Research Institute%'" get Name, Version, InstallDate, InstallLocation in a DOS window (at the suggestion of @MattWilkie) reports only the presence of Python 3.4.1 for ArcGIS Pro, ArcGIS Pro and ArcGIS Earth on my machine.
30106
My script takes separate 3D feature classes, calculates a field, appends to a target feature class, and then deletes the originals. This is a huge data processing task of over 4700 mass point feature classes appending to a single one. I know it was a big mistake to put so many feature classes into SDE, but given they're in there now, I've got to deal with them there (yes, the sheer fc count is bringing SDE performance to its knees--hence my urgency).  Early on it worked great, in that the merged result showed valid z-values. I was able to build a terrain and it looked great. I'd been running this in the background for weeks, and have just noticed z-values of 0 in the output, where the originals were not 0! Oh no!!! I'm certainly glad I still have the file-based originals!  Pseudocode:     An in_memory feature class is created from a z-aware template      For each fc in the feature dataset:            It is appended to the empty in_memory fc          The TILE_ID field is calculated using a portion of the name of the source fc           It is then appended to the target SDE fc          The in_memory feature class is emptied          Each processed fc is then deleted     When I initially posted, I was curious if it was my use of in_memory that caused this trouble. I had not initially been using it, and only switched to it because performance was far too slow otherwise, and WAY faster in_memory. To find where trouble started, I ran the Add XY Coordinates tool, which proved the trouble started with in_memory use. At that time I had also switched from CalculateField_management to da.UpdateCursor, so that's likely the bigger reason for the performance enhancement. I will now change my code to avoid in_memory.
117326
I have created multiple ESRI addins, where the same code is used. I have created a class library, which I can reference rather than duplicating code. I have the following in my ESRI addin code which works fine  IMxDocument mxdoc = ArcMap.Application.Document as IMxDocument;   However if the same code is used in the class library, I am unable to build the dll. As the  class library does not know about ArcMap,   I have tried   ESRI.ArcGIS.ArcMap.Application arcmapApp = new ESRI.ArcGIS.ArcMap.Application(); IMxDocument mxdoc = arcmapApp.Document as IMxDocument;   However when I run the code in my addin (that references my Class Library), i get the following error    What is the correct way of referencing ArcMap in a class library?
19614
This questions has been asked before too and I did go through most of the suggestions. Things I have tried so far: setting up correct  path variable environment, installing anaconda 32 bits, python 2.7, or even switching to python 2.7 in cmd while initially using Anaconda 3 , adding Desktop 10.4.pth file with  following path.  C:\Program Files (x86)\ArcGIS\Desktop10.4\bin C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcToolBox\Scripts   I also added those paths in environment variable   These suggestions help me to reduce the error. But Now I am getting a different error. Looks like python can find arcpy but missing another package.  Getting this error while trying to import arcpy in python 3.6.   File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\__init__.py", line 22, in &lt;module&gt;     from arcpy.geoprocessing import gp    File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\geoprocessing\__init__.py", line 14, in &lt;module&gt;     from _base import *  ModuleNotFoundError: No module named '_base'   Any suggestions?
13757
I'm moving all files to a new computer, via an external hard drive. I am certain that broken links will be a concern. What can I do to fix this? Is there a 'Best Practices' kind of way to prevent this problem beforehand? I have many hundreds of .blend files, and of course, I fear losing them.
78936
I am using the python script provided by arc help to publish map services but keep getting this error. I am using desktop ver 10.3 and publishing to arc server 10.1. Different version isn't a problem. I looked into that already. Here's what I'm getting..  Executing: StageService //gis/noble/Region/GulfOfMexico/MAPS/Rusty/PTRL_GOM_GBDS1.sddraft \\gis\noble\Region\GulfOfMexico\MAPS\Rusty\PTRL_GOM_GBDS1.sd Start Time: Wed Jul 27 12:58:45 2016 Submitted. Executing... Start Time: Wed Jul 27 12:58:57 2016 Succeeded at Wed Jul 27 12:58:58 2016 (Elapsed Time: 0.33 seconds) Succeeded. Succeeded at Wed Jul 27 12:58:58 2016 (Elapsed Time: 13.03 seconds) Executing: UploadServiceDefinition //gis/noble/Region/GulfOfMexico/MAPS/Rusty/PTRL_GOM_GBDS1.sd "GIS Servers\arcgis on hougsagis01.gs.nblenergy.com_6080 (publisher).ags" # # FROM_SERVICE_DEFINITION # STARTED USE_DEFINITION NO_SHARE_ONLINE PRIVATE NO_SHARE_ORGANIZATION # Start Time: Wed Jul 27 12:59:10 2016 Submitted. Executing... Executing (Publish Service Definition): PublishServiceDefinition i24681d7c-eb34-40ef-8223-32f7fc1c7e34 # {"buildInitialCache":false} # Start Time: Wed Jul 27 12:59:13 2016 Validating publish options. Connecting to the server. Getting basic item metadata for service definition upload. Getting server information (server folders, data stores, etc.). Extracting manifiest from uploaded service definition. Deriving arcgis server service from hosted service (hosted service definition). Validating service definition. Determining service's input folder name. Attempt to find service's input folder. Creating the service. ERROR 001487: Failed to update the published service with the server-side data location. Please see the server's log for more details. ERROR 001369: Failed to create the service. Failed to execute (Publish Service Definition). Failed at Wed Jul 27 12:59:14 2016 (Elapsed Time: 0.92 seconds) Failed. ERROR: the server's publishing job didn't succeed. Failed to execute (UploadServiceDefinition). Failed at Wed Jul 27 12:59:13 2016 (Elapsed Time: 3.01 seconds)   I cannot access the server folders past  Directory /opt/ags/arcgis/server/usr: permission denied. I cannot access the logs. Has anyone else run into this?
110701
I have ArcGIS Desktop 10.0 and have created a 1:m relationship in a File GDB. The 1:m relationship joins a table containing a URL to a point geometry. Some points have more than one file hence the 1:m join. After successfully creating the relationship, I wanted to use the field in the table to open the Image. It seems however, that ArcGIS stand-alone tables cannot use hyperlinks. Is there a workaround to this or can ArcGIS not use hyperlinks in stand-alone tables?
72486
As a test I have:   Authored a test.mxd with one layer called Localities in a single data frame called Layers Authored a test.rlf using View | Reports > Create Report of ArcGIS 10.2.2 for Desktop Created a Python AddIn which creates the expected PDF file from the Report (*.rlf).   This is the code which all works to create the PDF report from the Localities features within the current extent:  import arcpy  import pythonaddins  class ReportForExtent(object):     def __init__(self):         self.enabled = True         self.checked = False      def onClick(self):         mxd = arcpy.mapping.MapDocument("CURRENT")         df = arcpy.mapping.ListDataFrames(mxd,"Layers")[0]         lyr = arcpy.mapping.ListLayers(mxd,"Localities",df)[0]         arcpy.mapping.ExportReport(lyr,r"C:\temp\test.rlf",r"C:\temp\test.pdf","EXTENT",extent=df.extent)         del mxd   Is there a way to have the Python AddIn not just create the PDF file but also open it in Adobe Acrobat Reader?