AnsweredAssumed Answered

Error 000210 and 000354 when running Union analysis in a Python script.

Question asked by mattbeal on Jan 17, 2020
Latest reply on Jan 22, 2020 by mattbeal

Hello everyone! I've come across an issue that has completely stumped our entire organization. I'm currently working through the issue with ESRI support (who also seems stumped) as well but wanted to see if the broader community had any experience with this issue as well.

 

We have a python script that compares two cities and extracts the differences and doctors them up a bit for project standards. Naturally, the first stage of the script is calls for a union. On the first set of cities that I wanted to compare, I got the following error: 

 


PS Microsoft.PowerShell.Core\FileSystem::\\havc.local\misc\GIS\Regional\Boundary and Annexation Survey (BAS)\2020 BAS> python BASupdate.py
If the city is two words, do not add a space.

Enter city:
Aiken


Input Folder: \\havc.local\misc\GIS\Regional\Boundary and Annexation Survey (BAS)\2020 BAS\Aiken
MXD Path: \\havc.local\misc\GIS\Regional\Boundary and Annexation Survey (BAS)\2020 BAS\Aiken\AikenBAS.mxd
env.workspace: \\havc.local\misc\GIS\Regional\Boundary and Annexation Survey (BAS)\2020 BAS\Aiken\Aiken_2020.gdb
Creating the change polygons...
Traceback (most recent call last):
File "BASupdate.py", line 56, in <module>
arcpy.Union_analysis([censusData, havcData], unionFC)
File "C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\analysis.py", line 628, in Union
raise e
arcgisscripting.ExecuteError: ERROR 000210: Cannot create output \\havc.local\misc\GIS\Regional\Boundary and Annexation Survey (BAS)\2020 BAS\Aiken\Aiken_2020.gdb\union.shp.shp
ERROR 000354: The name contains invalid characters
Failed to execute (Union).

PS Microsoft.PowerShell.Core\FileSystem::\\havc.local\misc\GIS\Regional\Boundary and Annexation Survey (BAS)\2020 BAS>

 

As you can see, it looks like it is trying to export a shapefile into a geodatabase, but that is not what the code is telling it to do at all. Here is the entire code snippet up until that point: 

 

import os
import sys
import arcpy
from arcpy import env
import shutil
import subprocess


# Folder location will need to be changed every year
# There are two instances of the year in the script. Use the search function to find them.
basFolder = '\\\\havc.local\\misc\\GIS\\Regional\\Boundary and Annexation Survey (BAS)\\2020 BAS\\'


print "If the city is two words, do not add a space.\n"


# user to input the city name for the script
userInput = raw_input('Enter city:\n')
inputFolder = os.path.join(basFolder, userInput)
basReturnDirectory = os.path.join(basFolder, userInput + '\\BASReturn')


# check if folder exists
if os.path.exists(inputFolder):

print "\n"
# print out the input folder as specified by the user
print "Input Folder: " + inputFolder

# create BASReturn folder for final deliverables
if not os.path.exists(basReturnDirectory):
os.makedirs(basReturnDirectory)

# set the environment to list the mxds
arcpy.env.workspace = inputFolder

for file in arcpy.ListFiles("*.mxd"):

mxd_path = os.path.join(inputFolder, file)
print "MXD Path: " + mxd_path

# reset the environment to the database
env.workspace = inputFolder + '\\' + userInput + '_2020.gdb'
print "env.workspace: " + env.workspace
# map variables
mxd = arcpy.mapping.MapDocument(mxd_path)
df = arcpy.mapping.ListDataFrames(mxd, "*")[0]
havcData = arcpy.mapping.ListLayers(mxd, "HavcData", df)
censusData = arcpy.mapping.ListLayers(mxd, "CensusData", df)
unionFC = "union"
union_m2s = "union_multisingle"

# create the change polygons
print "Creating the change polygons..."

arcpy.Union_analysis([censusData, havcData], unionFC)

It seems to not be recognizing the env.workspace as being a geodatabase for some reason. 

As if that wasn't strange enough, I decided to try the tool on a different city and it worked flawlessly. That city's polygon's came out of the same feature classes that the one that failed did as well. Does anyone have any suggestions on what may be causing this? If I can provide any more information, please let me know! Thanks so much!

Outcomes