当前位置: 首页>>代码示例>>Python>>正文


Python arcpy.CopyFeatures_management方法代码示例

本文整理汇总了Python中arcpy.CopyFeatures_management方法的典型用法代码示例。如果您正苦于以下问题:Python arcpy.CopyFeatures_management方法的具体用法?Python arcpy.CopyFeatures_management怎么用?Python arcpy.CopyFeatures_management使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在arcpy的用法示例。


在下文中一共展示了arcpy.CopyFeatures_management方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testdlt

# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import CopyFeatures_management [as 别名]
def testdlt(self):
        est = []
        wc = '"OBJECTID" < 11'
        lr = arcpy.management.MakeFeatureLayer(self.t_fc, "lr", wc).getOutput(0)
        # TODO: test for deleting layers won't pass even though ap.dlt works
        #print lr
        #print arcpy.Exists(lr)
        tempfc = 'in_memory\\tmp'
        if arcpy.Exists(tempfc):
            arcpy.Delete_management(tempfc)
        tmpfc = arcpy.CopyFeatures_management(lr, tempfc).getOutput(0)
        tempshp = arcpy.CreateScratchName('tmp.dbf', workspace='c:\\temp').replace('.dbf', '.shp')
        fc = arcpy.CopyFeatures_management(tmpfc, tempshp).getOutput(0)
        ap.dlt(lr)
        est.append(ap.dlt(tmpfc))
        est.append(ap.dlt(fc))
        est.append(ap.dlt('this does not exist'))
        self.assertEquals(est, [True, True, False])
        pass 
开发者ID:NERC-CEH,项目名称:arcapi,代码行数:21,代码来源:arcapi_test.py

示例2: testadd_fields_from_table

# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import CopyFeatures_management [as 别名]
def testadd_fields_from_table(self):
        fc = os.path.join(self.testing_gdb, 'Illinois')
        copy = fc + '_copy'
        if arcpy.Exists(copy):
            arcpy.Delete_management(copy)
        arcpy.CopyFeatures_management(fc, copy)
        flds = ['POP1990', 'POP2000']
        tab = fc = os.path.join(self.testing_gdb, 'Illinois_county_info')
        ap.add_fields_from_table(copy, tab, flds)
        est = [f.name for f in arcpy.ListFields(copy)]
        try:
            arcpy.Delete_management(copy)
        except: pass
        for f in flds:
            self.assertTrue(f in est)
        pass 
开发者ID:NERC-CEH,项目名称:arcapi,代码行数:18,代码来源:arcapi_test.py

示例3: testjoin_using_dict

# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import CopyFeatures_management [as 别名]
def testjoin_using_dict(self):
        if arcpy.Exists(r'in_memory\copy'):
            arcpy.Delete_management(r'in_memory\copy')
        fc = os.path.join(self.testing_gdb, 'Illinois')
        copy = fc + '_copy'
        if arcpy.Exists(copy):
            arcpy.Delete_management(copy)
        arcpy.CopyFeatures_management(fc, copy)
        flds = ['POP1990', 'POP2000']
        tab = fc = os.path.join(self.testing_gdb, 'Illinois_county_info')
        ap.join_using_dict(copy, 'CNTY_FIPS', tab, 'CNTY_FIPS', flds)
        est = [f.name for f in arcpy.ListFields(copy)]
        try:
            arcpy.Delete_management(copy)
        except: pass
        for f in flds:
            self.assertTrue(f in est)
        pass 
开发者ID:NERC-CEH,项目名称:arcapi,代码行数:20,代码来源:arcapi_test.py

示例4: testconcatenate_fields

# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import CopyFeatures_management [as 别名]
def testconcatenate_fields(self):
        if arcpy.Exists(r'in_memory\copy'):
            arcpy.Delete_management(r'in_memory\copy')
        fc = os.path.join(self.testing_gdb, 'Illinois')
        copy = fc + '_copy'
        if arcpy.Exists(copy):
            arcpy.Delete_management(copy)
        arcpy.CopyFeatures_management(fc, copy)
        ap.concatenate_fields(copy, 'FULL', 75, ['NAME', 'STATE_NAME'], ' County, ')
        obs = 'Jo Daviess County, Illinois'
        with arcpy.da.SearchCursor(copy, 'FULL') as rows:
            est = rows.next()[0]
        del rows
        try:
            arcpy.Delete_management(copy)
        except: pass
        self.assertEqual(est, obs)
        pass 
开发者ID:NERC-CEH,项目名称:arcapi,代码行数:20,代码来源:arcapi_test.py

示例5: make_poly_from_extent

# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import CopyFeatures_management [as 别名]
def make_poly_from_extent(ext, sr):
    """Make an arcpy polygon object from an input extent object.,Returns
    a polygon geometry object.

    Required:
    ext -- extent object
    sr -- spatial reference

    Example
    >>> ext = arcpy.Describe(fc).extent
    >>> sr = 4326  #WKID for WGS 84
    >>> poly = make_poly_from_extent(ext, sr)
    >>> arcpy.CopyFeatures_management(poly, r'C:\Temp\Project_boundary.shp')
    """
    array = arcpy.Array()
    array.add(ext.lowerLeft)
    array.add(ext.lowerRight)
    array.add(ext.upperRight)
    array.add(ext.upperLeft)
    array.add(ext.lowerLeft)
    return arcpy.Polygon(array, sr) 
开发者ID:NERC-CEH,项目名称:arcapi,代码行数:23,代码来源:arcapi.py

示例6: createPolygon

# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import CopyFeatures_management [as 别名]
def createPolygon(self, lat, lon, extent, out_polygons, scratchWorkspace):
        """Create a Thiessen polygon feature class from numpy.ndarray lat and lon
           Each polygon represents the area described by the center point
        """
        buffer = 2 * max(abs(lat[0]-lat[1]),abs(lon[0] - lon[1]))
        # Extract the lat and lon within buffered extent (buffer with 2* interval degree)
        lat0 = lat[(lat >= (extent.YMin - buffer)) & (lat <= (extent.YMax + buffer))]
        lon0 = lon[(lon >= (extent.XMin - buffer)) & (lon <= (extent.XMax + buffer))]
        # Spatial reference: GCS_WGS_1984
        sr = arcpy.SpatialReference(4326)

        # Create a list of geographic coordinate pairs
        pointGeometryList = []
        for i in range(len(lon0)):
            for j in range(len(lat0)):
                point = arcpy.Point()
                point.X = float(lon0[i])
                point.Y = float(lat0[j])
                pointGeometry = arcpy.PointGeometry(point, sr)
                pointGeometryList.append(pointGeometry)

        # Create a point feature class with longitude in Point_X, latitude in Point_Y
        out_points = os.path.join(scratchWorkspace, 'points_subset')
        result2 = arcpy.CopyFeatures_management(pointGeometryList, out_points)
        out_points = result2.getOutput(0)
        arcpy.AddGeometryAttributes_management(out_points, 'POINT_X_Y_Z_M')

        # Create Thiessen polygon based on the point feature
        result3 = arcpy.CreateThiessenPolygons_analysis(out_points, out_polygons, 'ALL')
        out_polygons = result3.getOutput(0)

        return out_points, out_polygons 
开发者ID:Esri,项目名称:python-toolbox-for-rapid,代码行数:34,代码来源:CreateWeightTableFromECMWFRunoff.py

示例7: copyFlowlines

# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import CopyFeatures_management [as 别名]
def copyFlowlines(self, in_drainage_line, path_database, list_uniqueID):
        """Create copies of flowlines based on the layer query definitions"""
        # make a feature layer for query selection
        name_lyr = "flowlines"
        arcpy.MakeFeatureLayer_management(in_drainage_line, name_lyr)

        '''Create the query expression for line features with matching records in the flat table'''
        expression_base = self.name_ID + " IN ("
        count = len(list_uniqueID)
        counter = 1
        for each_ID in list_uniqueID:
            if counter == count:
                expression_base = expression_base + str(each_ID) + ")"
            else:
                expression_base = expression_base + str(each_ID) + ", "
            counter += 1


        for each_key in self.layer_minScale_maxScale_query.keys():
            out_copy = os.path.join(path_database, "Flowline_"+each_key)
            pars = self.layer_minScale_maxScale_query[each_key]
            query = pars[2]
            expression = expression_base
            if query is not None:
                expression = expression_base + "AND " + query

            arcpy.SelectLayerByAttribute_management(name_lyr, "NEW_SELECTION", expression)
            arcpy.CopyFeatures_management(name_lyr, out_copy)
            arcpy.AddIndex_management(out_copy, self.name_ID, self.name_ID, "UNIQUE", "ASCENDING")

        return 
开发者ID:Esri,项目名称:python-toolbox-for-rapid,代码行数:33,代码来源:CreateDischargeMap.py

示例8: execute

# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import CopyFeatures_management [as 别名]
def execute(self, parameters, messages):
        """The source code of the tool."""
        arcpy.env.overwriteOutput = True

        in_data = parameters[0].value
        in_workspace_server = parameters[1].valueAsText

        for row in in_data:
            data = row[0]
            name = os.path.basename(str(data))
            if "Discharge_Table" in name:
                outTable = os.path.join(in_workspace_server, name)
                # Copy discharge table
                arcpy.CopyRows_management(data, outTable, '#')
                # Add attribute index to the discharge table
                arcpy.AddIndex_management(outTable, self.fields_oi[1], self.fields_oi[1])
                arcpy.AddIndex_management(outTable, self.fields_oi[3], self.fields_oi[3])
            elif "Flowline_" in name:
                outFlowline = os.path.join(in_workspace_server, name)
                # Copy flowline feature class
                arcpy.CopyFeatures_management(data, outFlowline)
                # Add attribute index to the flowline feature class
                arcpy.AddIndex_management(outFlowline, self.name_ID, self.name_ID, "UNIQUE", "ASCENDING")
            else:
                arcpy.AddMessage("{0} is not copied due to incorrect name".format(name))


        return 
开发者ID:Esri,项目名称:python-toolbox-for-rapid,代码行数:30,代码来源:CopyDataToServer.py

示例9: merge_feature_class

# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import CopyFeatures_management [as 别名]
def merge_feature_class(merges, out_fc, cleanUp=True):
    """ merges featureclass into a single feature class """
    if arcpyFound == False:
        raise Exception("ArcPy is required to use this function")
    if cleanUp == False:
        if len(merges) == 0:
            return None
        elif len(merges) == 1:
            desc = arcpy.Describe(merges[0])
            if hasattr(desc, 'shapeFieldName'):
                return arcpy.CopyFeatures_management(merges[0], out_fc)[0]
            else:
                return arcpy.CopyRows_management(merges[0], out_fc)[0]
        else:
            return arcpy.Merge_management(inputs=merges,
                                          output=out_fc)[0]
    else:
        if len(merges) == 0:
            return None
        elif len(merges) == 1:
            desc = arcpy.Describe(merges[0])
            if hasattr(desc, 'shapeFieldName'):
                merged = arcpy.CopyFeatures_management(merges[0], out_fc)[0]
            else:
                merged = arcpy.CopyRows_management(merges[0], out_fc)[0]
        else:
            merged = arcpy.Merge_management(inputs=merges,
                                        output=out_fc)[0]
        for m in merges:
            arcpy.Delete_management(m)
            del m
        return merged
#---------------------------------------------------------------------- 
开发者ID:Esri,项目名称:ArcREST,代码行数:35,代码来源:spatial.py

示例10: combine_data

# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import CopyFeatures_management [as 别名]
def combine_data(fc_list, output_fc):
    """ :param fc_list: array of featureclass paths as strings
        :param output_fc: path to output dataset
        Combine the downloaded datafiles into one
        fastest approach is to use cursor
    """
    if len(fc_list) == 1:
        arcpy.Copy_management(fc_list[0], output_fc)
        output_msg("Created {0}".format(output_fc))
    else:
        for fc in fc_list:
            if fc_list.index(fc) == 0:
                # append to first dataset. much faster
                output_msg("Prepping yer first dataset {0}".format(fc))
                if arcpy.Exists(output_fc):
                    output_msg("Avast! {0} exists, deleting...".format(output_fc), severity=1)
                    arcpy.Delete_management(output_fc)
                
                arcpy.Copy_management(fc, output_fc)  # create dataset to append to
                output_msg("Created {0}".format(output_fc))

                fieldlist = []
                #fieldlist = ["SHAPE@"]
                fields = arcpy.ListFields(output_fc)
                for field in fields:
                    if field.name.lower() == u'shape':
                        fieldlist.insert(0, "SHAPE@") # add shape token to start
                    else:
                        fieldlist.append(field.name)
                #fields = [field.name for field in arcpy.ListFields(output_fc) if field.name.lower() not in [u'shape']]
                #fieldlist.extend(fields)
                ##arcpy.CopyFeatures_management(output_fc, fc) # duplicate first one so delete later doesn't fail
                insert_rows = arcpy.da.InsertCursor(output_fc, fieldlist)
            else:
                search_rows = arcpy.da.SearchCursor(fc, fieldlist) # append to first dataset
                for row in search_rows:
                    insert_rows.insertRow(row)
                del row, search_rows
                output_msg("Appended {0}...".format(fc))
        del insert_rows 
开发者ID:gdherbert,项目名称:DataPillager,代码行数:42,代码来源:DataServicePillager.py

示例11: testrename_col

# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import CopyFeatures_management [as 别名]
def testrename_col(self):
        import arcpy
        import tempfile
        owo = arcpy.env.overwriteOutput
        arcpy.env.overwriteOutput = True
        tmpfc = os.path.join(tempfile.gettempdir(), "tmp")
        tmpfc = arcpy.CopyFeatures_management(self.t_fc, tmpfc).getOutput(0)
        est = ap.rename_col(tmpfc, "ABBREV", "ABBREVIATION")
        obs = "ABBREVIATI"
        arcpy.Delete_management(tmpfc)
        arcpy.env.overwriteOutput = owo
        self.assertEqual(est, obs)
        pass 
开发者ID:NERC-CEH,项目名称:arcapi,代码行数:15,代码来源:arcapi_test.py

示例12: to_points

# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import CopyFeatures_management [as 别名]
def to_points(tbl, out_fc, xcol, ycol, sr, zcol='#', w=''):
    """Convert table to point feature class, return path to the feature class.

    Required:
    tbl -- input table or table view
    out_fc -- path to output feature class
    xcol -- name of a column in tbl that stores x coordinates
    ycol -- name of a column in tbl that stores y coordinates
    sr -- spatial reference for out_fc
        sr can be either arcpy.SpatialReference object or a well known id as int

    Optional:
    zcol -- name of a column in tbl that stores y coordinates, default is '#'
    w -- where clause to limit the rows of tbl considered, default is ''

    Example:
    >>> t = 'c:\\foo\\bar.shp'
    >>> o = 'c:\\foo\\bar_pts.shp'
    >>> table_to_points(t, o, "XC", "YC", 4326, zcol='#', w='"FID" < 10')
    >>> table_to_points(t, o, "XC", "YC", arcpy.SpatialReference(27700))
    >>> table_to_points(t, o, "XC", "YC", arcpy.describe(tbl).spatialReference)
    """
    lrnm = tstamp('lr', '%m%d%H%M%S', '')
    if type(sr) != arcpy.SpatialReference:
        sr = arcpy.SpatialReference(sr)
    lr = arcpy.MakeXYEventLayer_management(tbl, xcol, ycol, lrnm, sr, zcol).getOutput(0)
    if str(w) not in ('', '*'):
        arcpy.SelectLayerByAttribute_management(lr, "NEW_SELECTION", w)
    out_fc = arcpy.CopyFeatures_management(lr, out_fc).getOutput(0)
    dlt(lr)
    return (arcpy.Describe(out_fc).catalogPath) 
开发者ID:NERC-CEH,项目名称:arcapi,代码行数:33,代码来源:arcapi.py


注:本文中的arcpy.CopyFeatures_management方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。