# -*- coding: utf-8 -*-
"""
Created on Sun Apr 7 15:32:24 2019
@author:
"""

# XYTableToPoint.py
# Description: Creates a point feature class from input table

# import system modules
import arcpy
import csv
# Set environment settings
import os
rootdir =
outpath=

list = os.listdir(rootdir) #列出文件夹下所有的目录与文件
for i in range(0,len(list)):
path = os.path.join(rootdir,list[i])
print path
if os.path.isfile(path):
# Set the local variables
outputname = path[40:57]+"_"+path[58:73]+".shp"
print outputname
spatRef = arcpy.SpatialReference("WGS 1984") #"WGS 1984"
in_table = path
with open(in_table,'rb') as csvfile:
reader = csv.reader(csvfile)
column1 = [row[0] for row in reader]
with open(in_table,'rb') as csvfile:
reader = csv.reader(csvfile)
column2 = [row[1] for row in reader]
with open(in_table,'rb') as csvfile:
reader = csv.reader(csvfile)
end_lon = [row[2] for row in reader]
with open(in_table,'rb') as csvfile:
reader = csv.reader(csvfile)
end_lat = [row[3] for row in reader]
with open(in_table,'rb') as csvfile:
reader = csv.reader(csvfile)
distance = [row[4] for row in reader]
with open(in_table,'rb') as csvfile:
reader = csv.reader(csvfile)
speed = [row[5] for row in reader]
with open(in_table,'rb') as csvfile:
reader = csv.reader(csvfile)
angle = [row[6] for row in reader]
with open(in_table,'rb') as csvfile:
reader = csv.reader(csvfile)
u = [row[7] for row in reader]
with open(in_table,'rb') as csvfile:
reader = csv.reader(csvfile)
v = [row[8] for row in reader]

out_feature_class = "ice vector"
x_coords = column1 #"longitude"
y_coords = column2 # "latitude"
fc=arcpy.CreateFeatureclass_management(outpath, outputname, "POINT", "","","", spatRef)
arcpy.AddField_management(outpath+"\\"+outputname, "start_lon", "DOUBLE")
arcpy.AddField_management(outpath+"\\"+outputname, "start_lat", "DOUBLE")
arcpy.AddField_management(outpath+"\\"+outputname, "end_lon", "DOUBLE")
arcpy.AddField_management(outpath+"\\"+outputname, "end_lat", "DOUBLE")
arcpy.AddField_management(outpath+"\\"+outputname, "distance", "DOUBLE")#m
arcpy.AddField_management(outpath+"\\"+outputname, "speed", "DOUBLE")
arcpy.AddField_management(outpath+"\\"+outputname, "angle", "DOUBLE")
arcpy.AddField_management(outpath+"\\"+outputname, "u", "DOUBLE")
arcpy.AddField_management(outpath+"\\"+outputname, "v", "DOUBLE")
cursor=arcpy.InsertCursor(fc,["SHAPE@XY"]) # Add the point geometry to the feature vertex = arcpy.CreateObject("Point") vertex.X = line[0] vertex.Y =line[1] feature.shape = vertex # Add attributes feature.leibie = "shumu" # write to shapefile cursor.insertRow(feature) del cursor del fc
num=0
for x in x_coords:
feature = cursor.newRow() # Add the point geometry to the feature vertex = arcpy.CreateObject("Point") vertex.X = line[0] vertex.Y =line[1] feature.shape = vertex # Add attributes feature.leibie = "shumu" # write to shapefile cursor.insertRow(feature) del cursor del fc
# Add the point geometry to the feature
vertex = arcpy.CreateObject("Point")
vertex.X = float(x)
vertex.Y = float(y_coords[num])
feature.shape = vertex
feature.start_lon = float(x)
feature.start_lat = float(y_coords[num])
feature.end_lon = float(x)
feature.end_lat = float(y_coords[num])
feature.distance = float(distance[num])
feature.speed = float(speed[num])
feature.angle = float(angle[num])
feature.u = float(u[num])
feature.v = float(v[num])
#print vertex.X,vertex.Y,vertex.speed
cursor.insertRow(feature)
num=num+1
arcpy.DefineProjection_management(outpath+"\\"+outputname,spatRef)
# Add attributes
#z_coords = "elevation"

# Make the XY event layer...
# =============================================================================
# =============================================================================

# newfc="newpoint.shp"
# arcpy.CreateFeatureclass_management(outpath, newfc, "Point")
# cursor=arcpy.da.InsertCursor(newfc, ["SHAPE@"])
# array=arcpy.Array()

#
# # Print the total rows
# print(arcpy.GetCount_management(out_feature_class))
# =============================================================================
# =============================================================================
---------------------

arcpy利用XY创建点的更多相关文章

  1. Oracle Sales Cloud:管理沙盒(定制化)小细节1——利用公式创建字段并显示在前端页面

    Oracle Sales Cloud(Oracle 销售云)是一套基于Oracle云端的CRM管理系统.由于 Oracle 销售云是基于 Oracle 云环境的,它与传统的管理系统相比,显著特点之一便 ...

  2. 利用Oracle创建表空间和用户

    本文仅用于学习交流,商业用途请支持正版!转载请注明:http://www.cnblogs.com/mxbs/p/6217152.html 第一步,创建表空间 以SYS/sys账户和SYSDBA身份登录 ...

  3. 利用Oracle创建数据库

    本文仅用于学习交流,商业用途请支持正版!转载请注明:http://www.cnblogs.com/mxbs/p/6217151.html 数据库的创建 打开"所有程序"-" ...

  4. 利用navicat创建存储过程、触发器和使用游标的简单实例

    利用navicat创建存储过程.触发器和使用游标的简单实例 标签: navicat存储过程触发器mysql游标 2013-08-03 21:34 15516人阅读 评论(1) 收藏 举报  分类: 数 ...

  5. java中利用JFrame创建窗体 【转】

    1. 一个简单的swing public class Test(){ public static void main(String[] args){ JFrame frame = new JFrame ...

  6. IOS:利用dispatch_once创建单例

    在之前有一篇学习笔记中,记载了一篇如何在OC中实现单例的文章:<IOS学习笔记4—Objective C—创建单例>自苹果引入了Grand Central Dispatch (GCD)(M ...

  7. 利用WPF创建含多种交互特性的无边框窗体

    咳咳,标题一口气读下来确实有点累,让我先解释一下.另外文章底部有演示程序的下载. 本文介绍利用WPF创建一个含有以下特性的窗口: 有窗口阴影,比如QQ窗口外围只有几像素的阴影: 支持透明且无边框,为了 ...

  8. 编写利用Fragment创建新闻列表

    编写利用Fragment创建新闻列表 1.创建新闻实体类News,代码如下:   public class News { private String title; private String co ...

  9. 利用cocoapods创建基于git的私有库

    上一篇文章记录了我利用cocoapods创建基于SVN的私有库的全部过程,今天我再记录一下基于git创建的过程. 整体先说明一下创建一个私有的podspec包括如下那么几个步骤: 创建并设置一个私有的 ...

随机推荐

  1. android stdio 异常

    1.android studio gradle project sync failed File -> Settings 搜索Gradle 2.eqmu-system-i386未响应   分辨率 ...

  2. [转]POI读写Excel 修改

    [转]POI读写Excel 修改 一.Excel基础 二.HSSF概况 三.通过usermodel读取文件 四.通过usermodel写入文件 五.通过eventusermodel读取文件 六.HSS ...

  3. NSArray, NSSet, NSDictionary

    一.Foundation framework中用于收集cocoa对象(NSObject对象)的三种集合分别是: NSArray 用于对象有序集合(数组)NSSet 用于对象无序集合(集合) NSDic ...

  4. 同步 Github fork 分支

    /**************************************************************************** * 同步 Github fork 分支 * ...

  5. BZOJ_3105_[cqoi2013]新Nim游戏_线性基+博弈论

    BZOJ_3105_[cqoi2013]新Nim游戏_线性基+博弈论 Description 传统的Nim游戏是这样的:有一些火柴堆,每堆都有若干根火柴(不同堆的火柴数量可以不同).两个游戏者轮流操作 ...

  6. Spring事物注意事项

    一.尽量用注解声明事务 过去开发喜欢用tx:advice+aop命名空间方式来配置事务,一次配置对满足切点规则的方法永久生效.但也可能因此导致事务滥用,在不需要用到事务的地方用了会影响系统的并发性能. ...

  7. Spring Bean状态(转)

    Spring-beans的核心实体是BeanDefinition和BeanFactory.前者映射我们的定义,后者则是依据定义生产bean的工厂.  上图是spring beans的静态结构图,更多是 ...

  8. 《C-RNN-GAN: Continuous recurrent neural networks with adversarial training》论文笔记

    出处:arXiv: Artificial Intelligence, 2016(一年了还没中吗?) Motivation 使用GAN+RNN来处理continuous sequential data, ...

  9. bzoj 4584: [Apio2016]赛艇【dp】

    参考:https://www.cnblogs.com/lcf-2000/p/6809085.html 设f[i][j][k]为第i个学校派出的赛艇数量在区间j内,并且区间j内共有k个学校的方案数 把数 ...

  10. bzoj 2811: [Apio2012]Guard【线段树+贪心】

    关于没有忍者的区间用线段树判就好啦 然后把剩下的区间改一改:l/r数组表示最左/最右没被删的点,然后删掉修改后的左边大于右边的:l升r降排个序,把包含完整区间的区间删掉: 然后设f/g数组表示i前/后 ...