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

歡迎光臨散文網(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ó)家法律
松江区| 阿鲁科尔沁旗| 青田县| 越西县| 兴隆县| 长武县| 腾冲县| 长白| 平果县| 淮阳县| 澄城县| 铜山县| 贵德县| 怀远县| 延庆县| 会同县| 福鼎市| 留坝县| 亚东县| 漠河县| 三原县| 安新县| 盐边县| 拉萨市| 古交市| 泰兴市| 进贤县| 郎溪县| 司法| 白城市| 扎鲁特旗| 周口市| 翁牛特旗| 浦城县| 井研县| 榕江县| 武穴市| 渝中区| 广南县| 文山县| 新乐市|