Anda di halaman 1dari 2

#------------------------------------------------------------------------------# Name:

Create_Weekly_H20_FeatureClasses.py
# Purpose:
# For all the raw data text files (n=539) in the "txt_Final" folder:
# 1) Create XY event layer
# 2) Save event layer as a feature class with the same name as the text file
#
#
#
#
#
#

Author:

mbs7038

Created:
Copyright:
Licence:

18/12/2013
(c) mbs7038 2013
<your licence>

import arcpy
from arcpy import env
# Set environment settings
env.workspace = r"C:\Users\mbs7038\Documents\ArcGIS\FloodData\txt_FINAL"
savepath="C:\Users\mbs7038\Documents\ArcGIS\FloodData\Weekly_H20_Data.gdb"
tables=arcpy.ListTables("7*") # Only read tables that begin with the number 7
print "List Tables"
for table in tables:
try:
# DEFINE VARIABLES
# INPUTS
in_Table
x_coords
y_coords
z_coords

=
=
=
=

table
"Lon"
"Lat"
"wlevel"

# OUTPUT EVENT LAYER


out_Layer = table[:-4]
# NEW FEATURE CLASS PATH
# **FEATURE CLASSES CAN NOT BEGIN WITH A NUMBER**
# (HENCE THE "a" PRECEDING THE SERIAL DATE NUMBER OF THE TABLE NAME)
savefc = savepath + "/" + "a" + table[:-4]
#=======================================================================
# Make the XY event layer
# MakeXYEventLayer_management (table, in_x_field, in_y_field, out_layer,
#{spatial_reference}, {in_z_field})
# USE COORDINATE SYSTEM CODE FOR "WGS 1984" (4326) IN THE SPATIAL..
# REFERENCE SPACE.
print "Make XY event layer"
arcpy.MakeXYEventLayer_management(in_Table, x_coords, y_coords,
out_Layer, 4326, z_coords)
#=======================================================================
#=======================================================================
# Copy event layer to feature class

print "Copying features to feature class"


arcpy.CopyFeatures_management(out_Layer,savefc)
#=======================================================================
except:
# If an error occurred print the message to the screen
print arcpy.GetMessages()
print 'script complete!'

Anda mungkin juga menyukai