arcpy利用XY创建点

摘要:
#-*-编码:utf-8-*-“”CreatedonSunApr715:32:242019@author:“”“#XYTableToPoint.py#描述:从输入表#importsystemmodulesimportarcpyimportcsv#设置环境设置import


# -*- 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创建点》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇pip 安装PCB布局注意事项下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

c++STL之heap(堆)

1、误区! 1、堆排序排完后的堆和大顶堆、小顶堆不是一个概念!2、堆分为大顶堆和小顶堆,即要么大顶堆(大根堆/最大堆),要么小顶堆。3、对于堆,堆的根节点一定是堆中所有节点的最大值或者最小值。4、大顶堆只是说这个堆总每一个节点满足:每一个节点大于或者等于其左右娃。并非这个堆一定是从大到小的序列。5、所以才必须要有堆排序呀!堆排序排完了之后的,才一定是一个有...

mysql中的information_schema数据库表说明

1. 概述 information_schema 数据库跟 performance_schema 一样,都是 MySQL 自带的信息数据库。其中 performance_schema 用于性能分析,而 information_schema 用于存储数据库元数据(关于数据的数据),例如数据库名、表名、列的数据类型、访问权限等。 information_sch...

Windows Mysql8 设置大小写敏感

windows系统无法改成 lower_case_table_names=0, 因为windows默认是1,就算改也只能改成2,以下截自 MySQL 8.0 Reference Manual 然后,当我们按照网上方法把 my.ini中的lower_case_table_names强行改成2之后,会发现,mysql server无法启动了!!这是因为(下面...

自己写的一个随机生成ID号的函数(C#)

public string GetRandomNum(int num_down , int num_up){ //传递随机数的上下限 用于限制其长度 注意 num_up的值上限1000000000int re=0; Random ro=new Random(unchecked((int)DateTime.Now.Ticks));re=ro.Next(num...

antd-vue中table行高亮效果实现

【方式一】:通过设置customRow达到目的,点击时遍历所有行设置为正常颜色,把当前行设置为特殊颜色(高亮色) HTML: <a-table ref="table"size="small"rowKey="id"bordered :columns="physicalSurveyColumns":data-source="physicalSur...

mysql表碎片清理和表空间收缩

一、表碎片清理 存储结构分析 MySQL5.5默认是共享表空间 ,5.6中默认是独立表空间(表空间管理类型就这2种) 独立表空间 就是采用和MyISAM 相同的方式, 每个表拥有一个独立的数据文件( .idb )1.每个表都有自已独立的表空间。 2.每个表的数据和索引都会存在自已的表空间中。 3.可以实现单表在不同的数据库中移动(将一个库的表移动到另一个库...