Hi, I am a new ArcGis user.
I try to get a lan/lon of the neghborhoods of a region. Although my code runs w/o any problem, the output file which is a .txt file is not created/ or not seen in the dedicated directory.
Here is my script:
'''
## (i) Load arcpy and set working directory
#
import arcpy, os, getpass, shutil, copy, re
from shutil import copyfile
if getpass.getuser()=='xyz':
working_dir = 'fill in path'
elif getpass.getuser()=='esm':
working_dir = 'Z:/Documents/GitHub/amman'
os.chdir(working_dir)
arcpy.env.workspace = working_dir
arcpy.env.overwriteOutput = True #allows for overwriting files
#
## (ii) Useful shortcuts
#
temp_dir = '/tex/theory/pop_increase/temp/'
output_dir = working_dir + '/tex/theory/pop_increase/input/travel_time/'
spatial_reference = arcpy.SpatialReference("WGS 1984")
#
## (iii) Set up GDB for calculations
#
gdbDir = temp_dir
gdbName = 'traveltime'
gdbPath = gdbDir + gdbName + '.gdb'
if arcpy.Exists(gdbPath):
arcpy.Delete_management(gdbPath)
arcpy.CreateFileGDB_management(gdbDir, gdbName)
gdbPath =gdbPath +'/'
geography='Amman_zarqa'
source_dir=working_dir + '/raw/DoS/jordan_nh_shapfile/jordan_nh.shp'
# Step 2: Loading and transforming necessary layers
#-------------------------------------------------------
## (i) Projecting poligon layer for amman
#
in_data = source_dir
out_data = gdbPath + geography + '_projected'
arcpy.Project_management(in_data, out_data, spatial_reference)
grid_projected = out_data
## (ii) Transforming into the layer of centroids
#
centroids_name = geography + '_centroids'
arcpy.FeatureToPoint_management(grid_projected, gdbPath + centroids_name, "CENTROID")
centroids_projected = gdbPath + centroids_name
#
## (iii) Latitude and longitude
#
#arcpy.AddGeometryAttributes_management(centroids_projected, "POINT_X_Y_Z_M")
fieldnames = ['GRID_ID']
outfile = output_dir + "Amman_zarqa_latlon.txt"
if arcpy.Exists(outfile):
arcpy.Delete_management(outfile)
arcpy.ExportXYv_stats(centroids_name,fieldnames,"COMMA", outfile, "ADD_FIELD_NAMES")
#--------------------------------------------------------------
# Step 3: Delete unnecessary xml files
#--------------------------------------------------------------
directory = output_dir
file_list = os.listdir( directory )
for file in file_list:
if file.endswith(".xml"):
os.remove( os.path.join( directory, file ) )
In the ../input/travel_time, I can't see the file "Amman_zarqa_latlon.txt". What can be the reason for this ?
Thanks, in advance