AnsweredAssumed Answered

ArcPy script error

Question asked by Russel204 on Jul 12, 2016
Latest reply on Jul 13, 2016 by Russel204

Hello everyone,


I've got a question on arcpy. I have a script that is going to select some features out of a few hundred feature classes and export them based off of proximity to my desired location. My issue is I keep getting the 000210 which, to my understanding, means i do not have access to the database I'm trying to write to. I've included my script and error message below. If anyone has any ideas on what might be causing this, i would greatly appreciate the guidance.



Created by SGT Russel Klueg
11 JULY 16

About: This script is meant to increase the response time of data creation
by allowing for the earthquake to be put in and outputting KMLs of all critical
infrastructure within a set distance of the location.

import os, time, arcpy, csv
from arcpy import env

#Allows data to be overwritten
env.overwriteOutput = True
path = r'C:\Users\JOC-001\Desktop\Python Scripts\Earthquake\Earthquake Infrastructure.mxd'
#sets the path listed as the Map Document
mxd = arcpy.mapping.MapDocument(path)
#declares the Dataframe
df = "HSIP"
outPath = 'C:/Users/JOC-001/Documents/ArcGIS/Scratch.gdb/'
env.workspace = outPath
sr = arcpy.SpatialReference("WGS 1984")

#Takes the current time and creates a folder from it in YYYYMMDD HHMM format
current = time.strftime('%Y%m%d %H%M')
earthquake = 'C:/Users/JOC-001/Desktop/Python Scripts/Earthquake/'
folder = earthquake + current + '/'
print("The output folder for this entire process is below:\n" + folder)

#the next few lines take a verified user input to use as the Lat and Long 
lat = float(raw_input("Please enter the Latitude of the event." + \
                    "\nNumber should range between between 36.5 and 42.5\n"))
while lat < 36.5 or lat > 42.5:
    lat = float(raw_input("Please enter a valid Latitude between 36.5 and 42.5\n"))
long = float(raw_input("Please enter the Longitude of the event." + \
                    "\nNumber should range between between -87 and -92\n"))
while long < -92 or long > -87:
    long = float(raw_input("Please enter a valid Longitude between -87 and -92\n"))

finalCoords = folder + 'coords.csv'
#Creates a csv file and moves it into the appropriate folder
with open('coords.csv', 'wb') as coords:
    writer = csv.writer(coords, delimiter=',')
    data = [['Lat', 'Long'],[lat, long]]
os.rename(earthquake+'coords.csv', finalCoords)

#Creatst the layer, converts to .shp and buffers it at 50 miles.
eventPoint = folder + 'event.lyr'
arcpy.MakeXYEventLayer_management(finalCoords, 'Long', 'Lat', 'Event', sr)
arcpy.SaveToLayerFile_management('Event', eventPoint)
arcpy.FeatureClassToFeatureClass_conversion(eventPoint, outPath, 'finalPoint')
arcpy.Buffer_analysis(outPath + 'finalPoint', 'pointBuffer', '50 Miles')
bufferFile = outPath + 'pointBuffer'

#Iterates through every single layer in the MXD and selects data and exports it.
for lyr in arcpy.mapping.ListLayers(mxd):
    if not lyr.isGroupLayer:
        name =
        arcpy.SelectLayerByLocation_management(lyr, 'INTERSECT', bufferFile)
        arcpy.CopyFeatures_management(lyr, name)



Traceback (most recent call last):

  File "C:\Users\JOC-001\Desktop\Python Scripts\Earthquake\", line 67, in <module>

    arcpy.CopyFeatures_management(lyr, name)

  File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\", line 2429, in CopyFeatures

    raise e

ExecuteError: ERROR 000210: Cannot create output C:/Users/JOC-001/Documents/ArcGIS/Scratch.gdb\Animal Aquaculture Facilities

Failed to execute (CopyFeatures).