无码av一区二区三区无码,在线观看老湿视频福利,日韩经典三级片,成 人色 网 站 欧美大片在线观看

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

arcpy開(kāi)發(fā)實(shí)例之a(chǎn)dd-in代碼

2022-11-12 21:54 作者:夕林泉石  | 我要投稿

import arcpy

import pythonaddins


class BtnEditFeature(object):

? ? """Implementation for pydemoaddin_addin.button_edit (Button)"""

? ? def __init__(self):

? ? ? ? self.enabled = True

? ? ? ? self.checked = False

? ? def onClick(self):

? ? ? ? with arcpy.da.UpdateCursor("points",["name","OID@"]) as cursor:

? ? ? ? ? ? for row in cursor:

? ? ? ? ? ? ? ? row[0]="point_"+str(row[1]);

? ? ? ? ? ? ? ? cursor.updateRow(row);


class BtnNewFeatureClass(object):

? ? """Implementation for pydemoaddin_addin.button_newfeatureclass (Button)"""

? ? def __init__(self):

? ? ? ? self.enabled = True

? ? ? ? self.checked = False

? ? def onClick(self):

? ? ? ? if arcpy.Exists("d:/temp/points.shp"):

? ? ? ? ? ? arcpy.management.Delete("d:/temp/points.shp");

? ? ? ? arcpy.management.CreateFeatureclass("d:/temp","points.shp","POINT");

? ? ? ? arcpy.management.AddField("d:/temp/points.shp","name","TEXT",20);


? ? ? ? pythonaddins.MessageBox("Create point.shp successfully!","TIP");


class ToolDrawPoint(object):

? ? """Implementation for pydemoaddin_addin.tool_drawpoint (Tool)"""

? ? def __init__(self):

? ? ? ? self.enabled = True

? ? ? ? self.cursor = 3;

? ? ? ? self.shape = "NONE" # Can set to "Line", "Circle" or "Rectangle" for interactive shape drawing and to activate the onLine/Polygon/Circle event sinks.

? ?

? ? def onMouseDownMap(self, x, y, button, shift):

? ? ? ? with arcpy.da.InsertCursor("d:/temp/points.shp",['SHAPE@XY']) as dc:

? ? ? ? ? ? dc.insertRow([(x,y)]);

? ? ? ? ? ? print ("One point at the mouse position({0},{1}) has been added.".format(x,y);

? ? ? ? mxd = arcpy.mapping.MapDocument("current");

? ? ? ? df = mxd.activeDataFrame;

? ? ? ? ext = df.extent;

? ? ? ? extent = ext

? ? ? ? ext.XMin = ext.XMin-0.1

? ? ? ? df.extent = ext;

? ?

class ToolIdentify(object):

? ? """Implementation for pydemoaddin_addin.tool_identify (Tool)"""

? ? def __init__(self):

? ? ? ? self.enabled = True

? ? ? ? self.shape = "NONE" # Can set to "Line", "Circle" or "Rectangle" for interactive shape drawing and to activate the onLine/Polygon/Circle event sinks.

? ?

? ? def onMouseDownMap(self, x, y, button, shift):

? ? ? ?

? ? ? ? mxd = arcpy.mapping.MapDocument("current");

? ? ? ? df = mxd.activeDataFrame;

? ? ? ? lyr = arcpy.mapping.ListLayers(mxd,"points",df)[0];


? ? ? ? pt = arcpy.Point(x,y);

? ? ? ? geom = arcpy.PointGeometry(pt)

? ? ? ?

? ? ? ? arcpy.SelectLayerByLocation_management( "points","WITHIN_A_DISTANCE" ,geom,0.1);

? ? ? ? selectedCount = arcpy.GetCount_management("points");

? ? ? ?

? ? ? ? if selectedCount>0: ? ? ? ? ? ?

? ? ? ? ? ? for f in lyr.getSelectionSet():

? ? ? ? ? ? ? ? print f;

? ?


class ToolRemove(object):

? ? """Implementation for pydemoaddin_addin.tool_remove (Tool)"""

? ? def __init__(self):

? ? ? ? self.enabled = True

? ? ? ? self.shape = "NONE" # Can set to "Line", "Circle" or "Rectangle" for interactive shape drawing and to activate the onLine/Polygon/Circle event sinks.

? ?

? ? def onRectangle(self, rectangle_geometry):

? ? ? ? mxd = arcpy.mapping.MapDocument("current");

? ? ? ? df = mxd.activeDataFrame;

? ? ? ? lyr = arcpy.mapping.ListLayers(mxd,"points",df)[0];


? ? ? ? rect = rectangle_geometry;

? ? ? ? arcpy.SelectLayerByLocation_management( "points","WITHIN" ,rect);

? ? ? ? selectedCount = arcpy.GetCount_management("points");

? ? ? ?

? ? ? ? if selectedCount>0:

? ? ? ? ? ? arcpy.da.UpdateCursor("points",)

? ? ? ? ? ? with arcpy.da.UpdateCursor("points","OID@") as cursor:

? ? ? ? ? ? for f in lyr.getSelectionSet():

? ? ? ? ? ? ? ? for row in cursor:

? ? ? ? ? ? ? ? ? ? if row[0]==f:

? ? ? ? ? ? ? ? ? ? ? ? cursor.deleteRow(); ? ? ? ? ?

? ? ? ? ? ? ? ?

? ? ? ? ? ? ? ?


arcpy開(kāi)發(fā)實(shí)例之a(chǎn)dd-in代碼的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
易门县| 新龙县| 松江区| 中超| 天柱县| 墨玉县| 定兴县| 绍兴县| 娄底市| 开鲁县| 满洲里市| 崇明县| 嫩江县| 汾阳市| 和顺县| 香港| 深圳市| 灵山县| 韶山市| 浠水县| 瑞昌市| 东辽县| 山西省| 泰顺县| 沙河市| 洛隆县| 平远县| 博兴县| 通榆县| 萝北县| 阿合奇县| 毕节市| 嘉祥县| 呼伦贝尔市| 如东县| 张家界市| 牟定县| 濉溪县| 六枝特区| 无锡市| 仙居县|