# -*- 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. C # 踩坑记录(20190603)

    由于公司战略层需求,需要学习c#,在此仅记录相关问题,以便后期回顾. 学习路线 .NET 框架学习与C # 的关系 Visual Studio 简介及相关帮助网站(msdn) Main 方法及&quo ...

  2. Java 基本类型和对象类型的区别

    Java 基本类型和对象类型的区别 基本类型: int long byte float double char boolean short 对象类型: Integer Long Byte Float ...

  3. linux内存管理之uboot第一步

    在进入讲解linux内存管理的kernel阶段以前,了解一下uboot阶段是如何准备好内存物理设备的,这是非常有意义的.通常进入到linux内核阶段之后,对内存芯片的物理特性寄存器访问是比较少的,强调 ...

  4. Struts2自定义返回Json类型result

    本来Struts2有自己的json类型的返回结果,并提供了插件,但是它有一个问题,那就是它会将所有序列化的字段都返回,如果想要制定返回Action的某一个属性,则需要在配置result时,配置参数(这 ...

  5. CI框架中一个类中调用另一个类中已经加载对象测试

    controller.php <?php class CI_Controller { private static $instance; public function __construct( ...

  6. 51nod 1119 机器人走方格 V2 【组合数学】

    挺水的但是我好久没写组合数了- 用这样一个思想,在1~m列中,考虑每一列上升几格,相当于把n-1个苹果放进m个篮子里,可以为空,问有几种方案. 这个就是一个组合数学经典问题了,考虑n个苹果放进m个篮子 ...

  7. (8)css表格

    用css设置表格样式 *<table></table> 标签定义 HTML 表格. * tr 元素定义表格的行:th 元素定义表格的表头:td 元素定义表格中的单元格:capt ...

  8. Luogu P1186 玛丽卡 【最短路】By cellur925

    题目描述 麦克找了个新女朋友,玛丽卡对他非常恼火并伺机报复. 因为她和他们不住在同一个城市,因此她开始准备她的长途旅行. 在这个国家中每两个城市之间最多只有一条路相通,并且我们知道从一个城市到另一个城 ...

  9. 标准行cp功能

    #include<stdio.h> int main(int argc,char *argv[]) { FILE *src_fp,*des_fp; ]={}; ) { printf(&qu ...

  10. 洛谷 P1966 火柴排队

    题目描述 涵涵有两盒火柴,每盒装有 n 根火柴,每根火柴都有一个高度. 现在将每盒中的火柴各自排成一列, 同一列火柴的高度互不相同, 两列火柴之间的距离定义为:∑(ai​−bi​)2 其中ai​ 表示 ...