最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

arcpy開(kāi)發(fā)實(shí)例之管線自動(dòng)構(gòu)建

2022-11-11 10:09 作者:夕林泉石  | 我要投稿

# _*_ encoding: utf-8 _*_


import arcpy

arcpy.env.workspace = "d:/temp/pipe_data";


if arcpy.Exists("points.shp"):

? ? arcpy.management.Delete("points.shp");? ??

arcpy.management.CreateFeatureclass("d:/temp/pipe_data","points.shp","POINT",spatial_reference=arcpy.SpatialReference(3857));


if arcpy.Exists("lines.shp"):

? ? arcpy.management.Delete("lines.shp");? ??

arcpy.management.CreateFeatureclass("d:/temp/pipe_data","lines.shp","POLYLINE",spatial_reference=arcpy.SpatialReference(3857));


arcpy.AddField_management("points","expno","TEXT",5);

arcpy.AddField_management("points","mapno","TEXT",5);

arcpy.AddField_management("points","surfh","FLOAT");

arcpy.AddField_management("points","wdeep","FLOAT");


arcpy.AddField_management("lines","spoint","TEXT",5);

arcpy.AddField_management("lines","epoint","TEXT",5);


# 讀取XLS

import xlrd

xls = xlrd.open_workbook("d:/temp/pipe_data/ws_point.xlsx");

sht = xls.sheets()[0];

rn = sht.nrows;

cn = sht.ncols;


points = [];

with arcpy.da.InsertCursor("points",["expno","mapno","surfh","wdeep","SHAPE@XY"]) as cursor:? ??

? ? for i in range(1,rn):

? ? ? ? print " Read row : ",i;

? ? ? ? ctype = sht.cell_type(i,0);

? ? ? ? if ctype == 0:

? ? ? ? ? ? expno="";

? ? ? ? elif ctype ==1 :

? ? ? ? ? ? expno = sht.cell(i,0).value;

? ? ? ??

? ? ? ? ctype = sht.cell_type(i,1);

? ? ? ? if ctype == 0:

? ? ? ? ? ? mapno="";

? ? ? ? elif ctype ==1 :

? ? ? ? ? ? mapno = sht.cell(i,1).value;


? ? ? ? ctype = sht.cell_type(i,4);

? ? ? ? if ctype == 0:

? ? ? ? ? ? surfh=0;

? ? ? ? elif ctype ==1 :

? ? ? ? ? ?surfh = float(sht.cell(i,4).value);

? ? ? ? elif ctype==2:

? ? ? ? ? ? surfh = sht.cell(i,4).value;

? ? ? ? else:

? ? ? ? ? ? surfh = 0;

? ? ? ??

? ? ? ? ctype = sht.cell_type(i,5);

? ? ? ? if ctype == 0:

? ? ? ? ? ? wdeep=0;

? ? ? ? elif ctype ==1 :

? ? ? ? ? ?wdeep = float(sht.cell(i,5).value);

? ? ? ? elif ctype==2:

? ? ? ? ? ? wdeep = sht.cell(i,5).value;

? ? ? ? else:

? ? ? ? ? ? wdeep = 0;


? ? ? ? ctype = sht.cell_type(i,2);

? ? ? ? if ctype == 0 or ctype>2:

? ? ? ? ? ? continue;

? ? ? ? elif ctype == 1:

? ? ? ? ? ? x = float(sht.cell(i,2).value);

? ? ? ? else:

? ? ? ? ? ? x = sht.cell(i,2).value;


? ? ? ? ctype = sht.cell_type(i,3);

? ? ? ? if ctype == 0 or ctype>2:

? ? ? ? ? ? continue;

? ? ? ? elif ctype == 1:

? ? ? ? ? ? y = float(sht.cell(i,3).value);

? ? ? ? else:

? ? ? ? ? ? y = sht.cell(i,3).value;

? ? ? ??

? ? ? ? row = [expno,mapno,surfh,wdeep,(x,y)];

? ? ? ? points.append(row);

? ? ? ? cursor.insertRow(row);


# 讀取線表,并構(gòu)建線


xls = xlrd.open_workbook("d:/temp/pipe_data/ws_line.xlsx");

sht = xls.sheets()[0];

rn = sht.nrows;

cn = sht.ncols;


with arcpy.da.InsertCursor("lines",["spoint","epoint","SHAPE@"]) as cursor:

? ? for i in range(1,rn):

? ? ? ? print " Read row : ",i;

? ? ? ? ctype = sht.cell_type(i,1);

? ? ? ? if ctype !=1:

? ? ? ? ? ? continue;

? ? ? ? else :

? ? ? ? ? ? spoint = sht.cell(i,1).value;

? ? ? ??

? ? ? ? ctype = sht.cell_type(i,2);

? ? ? ? if ctype != 1:

? ? ? ? ? ? continue;

? ? ? ? else :

? ? ? ? ? ? epoint = sht.cell(i,2).value;


? ? ? ? for x in points:

? ? ? ? ? ? if x[0]==spoint:

? ? ? ? ? ? ? ? pt1 = x;

? ? ? ? ? ? ? ? break;

? ? ? ? for x in points:

? ? ? ? ? ? if x[0]==epoint:

? ? ? ? ? ? ? ? pt2 = x;

? ? ? ? ? ? ? ? break;

? ? ? ? arr = arcpy.Array();

? ? ? ? arr.append(arcpy.Point(pt1[4][0],pt1[4][1]));

? ? ? ? arr.append(arcpy.Point(pt2[4][0],pt2[4][1]));

? ? ? ? line = arcpy.Polyline(arr);

?

? ? ? ? row = [pt1[0],pt2[0],line];

? ? ? ? cursor.insertRow(row);


arcpy開(kāi)發(fā)實(shí)例之管線自動(dòng)構(gòu)建的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
常德市| 吐鲁番市| 红安县| 临颍县| 台南市| 高安市| 荆州市| 开封市| 墨玉县| 明星| 司法| 彝良县| 西昌市| 天峨县| 砚山县| 靖西县| 龙南县| 锦州市| 壶关县| 达拉特旗| 望都县| 城固县| 古蔺县| 高安市| 红原县| 新安县| 容城县| 梁山县| 台中市| 蒙城县| 体育| 保德县| 雅江县| 镇江市| 理塘县| 乌什县| 临泉县| 象州县| 永川市| 奉贤区| 南川市|