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

歡迎光臨散文網(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ó)家法律
咸宁市| 金乡县| 绥宁县| 阿拉尔市| 新泰市| 普宁市| 全州县| 波密县| 墨竹工卡县| 连云港市| 津市市| 驻马店市| 祁门县| 柏乡县| 宜兰县| 宕昌县| 阜康市| 彭阳县| 思南县| 敦煌市| 来宾市| 峡江县| 娄烦县| 开远市| 镇坪县| 潼关县| 察隅县| 行唐县| 达州市| 旺苍县| 汕尾市| 邳州市| 云龙县| 三台县| 蕉岭县| 赤峰市| 百色市| 汽车| 双牌县| 甘孜| 青田县|