国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(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ó)家法律
潞西市| 林周县| 基隆市| 辽源市| 英吉沙县| 吕梁市| 虞城县| 时尚| 汾西县| 讷河市| 桃园市| 皮山县| 赤峰市| 肇东市| 富阳市| 青河县| 本溪| 古浪县| 嵩明县| 壤塘县| 德昌县| 大新县| 宜阳县| 三明市| 托克托县| 大同市| 赣州市| 嘉祥县| 永安市| 嘉禾县| 分宜县| 邯郸市| 简阳市| 鹰潭市| 怀来县| 中卫市| 从化市| 安达市| 明星| 汝南县| 买车|