# -*- coding: utf-8 -*-
import arcpy
from arcpy import env
import glob
import os
import arcgisscripting
gp=arcgisscripting.create()
spatial_ref=r'C:\Users\zoe\Documents\ArcGIS\unionCopy2.prj' #转换点文件需要的投影信息数据prj
env.workspace =r'E:\GSM_GRACE\JPL\JPL2002_2017TIF\New_509\RF_Simulated_1km' #工作环境设置、输入路径
pathout=r'E:\GSM_GRACE\JPL\JPL2002_2017TIF\New_509\RF_Simulated_Shp' #输出文件路径
# 点文件信息
x_corrods='lon' #经度字段
y_corrods='lat' #纬度字段
Z_filed='GWSA' # 转换点文件需要保留的字段
try:
for file1 in arcpy.ListFiles("*.csv"): #列出当前工作环境下csv文件
print file1
info=os.path.basename(file1).split('.')[0] #获取csv文件的基本文件名,并去掉后缀
intable=file1 #转换点文件的输入表
outlayer=info #输出图层名称
print'outlayer',outlayer
gp.MakeXYEventLayer_management(intable,x_corrods,y_corrods,outlayer,spatial_ref,Z_filed) #建立XY事件图层
print'MakeXYEventLayer over'
## OUTdata=gp.describe(outlayer)
## print gp.getparameter(outlayer) #输出数据参数信息
## print'OUTdata over '
gp.FeatureClassToShapefile_conversion(outlayer,pathout) #将图层要素类转为shp
print'ToShapefile over'
except:
print gp.GetMessages()