arcpy利用XY创建点
# -*- 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创建点的更多相关文章
- Oracle Sales Cloud:管理沙盒(定制化)小细节1——利用公式创建字段并显示在前端页面
Oracle Sales Cloud(Oracle 销售云)是一套基于Oracle云端的CRM管理系统.由于 Oracle 销售云是基于 Oracle 云环境的,它与传统的管理系统相比,显著特点之一便 ...
- 利用Oracle创建表空间和用户
本文仅用于学习交流,商业用途请支持正版!转载请注明:http://www.cnblogs.com/mxbs/p/6217152.html 第一步,创建表空间 以SYS/sys账户和SYSDBA身份登录 ...
- 利用Oracle创建数据库
本文仅用于学习交流,商业用途请支持正版!转载请注明:http://www.cnblogs.com/mxbs/p/6217151.html 数据库的创建 打开"所有程序"-" ...
- 利用navicat创建存储过程、触发器和使用游标的简单实例
利用navicat创建存储过程.触发器和使用游标的简单实例 标签: navicat存储过程触发器mysql游标 2013-08-03 21:34 15516人阅读 评论(1) 收藏 举报 分类: 数 ...
- java中利用JFrame创建窗体 【转】
1. 一个简单的swing public class Test(){ public static void main(String[] args){ JFrame frame = new JFrame ...
- IOS:利用dispatch_once创建单例
在之前有一篇学习笔记中,记载了一篇如何在OC中实现单例的文章:<IOS学习笔记4—Objective C—创建单例>自苹果引入了Grand Central Dispatch (GCD)(M ...
- 利用WPF创建含多种交互特性的无边框窗体
咳咳,标题一口气读下来确实有点累,让我先解释一下.另外文章底部有演示程序的下载. 本文介绍利用WPF创建一个含有以下特性的窗口: 有窗口阴影,比如QQ窗口外围只有几像素的阴影: 支持透明且无边框,为了 ...
- 编写利用Fragment创建新闻列表
编写利用Fragment创建新闻列表 1.创建新闻实体类News,代码如下: public class News { private String title; private String co ...
- 利用cocoapods创建基于git的私有库
上一篇文章记录了我利用cocoapods创建基于SVN的私有库的全部过程,今天我再记录一下基于git创建的过程. 整体先说明一下创建一个私有的podspec包括如下那么几个步骤: 创建并设置一个私有的 ...
随机推荐
- YTU 2905: The Sum of 1...N
2905: The Sum of 1...N 时间限制: 1 Sec 内存限制: 128 MB 提交: 281 解决: 51 题目描述 Given an integer n,your task i ...
- ValueError: Some of types cannot be determined by the first 100 rows, please try again with sampling
ValueError: Some of types cannot be determined by the first 100 rows, please try again with sampling ...
- 二:多线程--GCD
一.简单介绍 1.GCD全称是Grand Central Dispatch,可译为“牛逼的中枢调度器”,纯C语言,提供了非常多强大的函数 2.GCD的优势 GCD是苹果公司为多核的并行运算提出的解决方 ...
- 并不对劲的bzoj4651:loj2086:uoj222:p1712:[NOI2016]区间
题目大意 有\(n\)(\(n\leq 5*10^5\))个闭区间\([L_1,R_1],[L_2,R_2],...,[L_n,R_n]\)(\(\forall i\in [1,n],0\leq L_ ...
- 警告框在asp.net mvc中应用
Bootstrap与asp.net MVC框架结合,产生警告框.主要是利用控制器的TempData 字典对象 生成临时数据. ASP.NET MVC的TempData用于传输一些临时的数据,例如在各个 ...
- 2-17 numpy模块使用
#CURD import numpy as np data1 = np.array([1,2,3,4,5]) print(data1) data2 = np.array([[1,2], [3,4]]) ...
- 美化console.log的文本(转载)
原文地址:http://www.css88.com/archives/5260 JavaScript Console 那些少人所知的特性 console.log("%c css88.com& ...
- CollabNetSubversionEdge 4.0.4教程
CollabNetSubversionEdge是svn的集成环境,集合subversion,apache,viewvc, 参考网址:http://blog.miniasp.com/post/2011/ ...
- 【黑金教程笔记之005】【建模篇】【Lab 04 消抖模块之二】—笔记
实验四和实验三的区别在于输出.实验三是检测到由高到低的电平变化时就拉高输出,检测到由低到高的电平变化时就拉低输出.而实验四检测到由高到低的电平变化时产生一个100ms的高脉冲.当检测到由低到高的电平变 ...
- 洛谷P3569 [POI2014]KAR-Cards(线段树)
传送门 蠢了…… 我们用线段树,记$w0$为该区间最左端取小值时,最右端最小能取大还是小还是无解,$w1$表示最左端取大值时,最右端最小能取大还是小还是无解 然后只要把交换看做修改就好了 这么说可能很 ...