本文整理汇总了Python中arcpy.CreateFeatureclass_management方法的典型用法代码示例。如果您正苦于以下问题:Python arcpy.CreateFeatureclass_management方法的具体用法?Python arcpy.CreateFeatureclass_management怎么用?Python arcpy.CreateFeatureclass_management使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arcpy
的用法示例。
在下文中一共展示了arcpy.CreateFeatureclass_management方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_cls_boundary
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import CreateFeatureclass_management [as 别名]
def generate_cls_boundary(cls_input,cntr_id_field,boundary_output,cpu_core):
arcpy.env.parallelProcessingFactor=cpu_core
arcpy.SetProgressorLabel('Generating Delaunay Triangle...')
arrays=arcpy.da.FeatureClassToNumPyArray(cls_input,['SHAPE@XY',cntr_id_field])
cid_field_type=[f.type for f in arcpy.Describe(cls_input).fields if f.name==cntr_id_field][0]
delaunay=Delaunay(arrays['SHAPE@XY']).simplices.copy()
arcpy.CreateFeatureclass_management('in_memory','boundary_temp','POLYGON',spatial_reference=arcpy.Describe(cls_input).spatialReference)
fc=r'in_memory\boundary_temp'
arcpy.AddField_management(fc,cntr_id_field,cid_field_type)
cursor = arcpy.da.InsertCursor(fc, [cntr_id_field,"SHAPE@"])
arcpy.SetProgressor("step", "Copying Delaunay Triangle to Temp Layer...",0, delaunay.shape[0], 1)
for tri in delaunay:
arcpy.SetProgressorPosition()
cid=arrays[cntr_id_field][tri[0]]
if cid == arrays[cntr_id_field][tri[1]] and cid == arrays[cntr_id_field][tri[2]]:
cursor.insertRow([cid,arcpy.Polygon(arcpy.Array([arcpy.Point(*arrays['SHAPE@XY'][i]) for i in tri]))])
arcpy.SetProgressor('default','Merging Delaunay Triangle...')
if '64 bit' in sys.version:
arcpy.PairwiseDissolve_analysis(fc,boundary_output,cntr_id_field)
else:
arcpy.Dissolve_management(fc,boundary_output,cntr_id_field)
arcpy.Delete_management(fc)
return
示例2: create_feature_class
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import CreateFeatureclass_management [as 别名]
def create_feature_class(out_path,
out_name,
geom_type,
wkid,
fields,
objectIdField):
""" creates a feature class in a given gdb or folder """
if arcpyFound == False:
raise Exception("ArcPy is required to use this function")
arcpy.env.overwriteOutput = True
field_names = []
fc =arcpy.CreateFeatureclass_management(out_path=out_path,
out_name=out_name,
geometry_type=lookUpGeometry(geom_type),
spatial_reference=arcpy.SpatialReference(wkid))[0]
for field in fields:
if field['name'] != objectIdField:
field_names.append(field['name'])
arcpy.AddField_management(out_path + os.sep + out_name,
field['name'],
lookUpFieldType(field['type']))
return fc, field_names
#----------------------------------------------------------------------
示例3: execute
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import CreateFeatureclass_management [as 别名]
def execute(in_datasets, out_fc):
# use gcs as output sr since all extents will fit in it
out_sr = arcpy.SpatialReference("WGS 1984")
in_datasets = in_datasets.split(";")
arcpy.CreateFeatureclass_management(os.path.dirname(out_fc),
os.path.basename(out_fc),
"POLYGON",
spatial_reference=out_sr)
arcpy.AddField_management(out_fc, "dataset", "TEXT", 400)
# add each dataset's extent & the dataset's name to the output
with arcpy.da.InsertCursor(out_fc, ("SHAPE@", "dataset")) as cur:
for i in in_datasets:
d = arcpy.Describe(i)
ex = d.Extent
pts = arcpy.Array([arcpy.Point(ex.XMin, ex.YMin),
arcpy.Point(ex.XMin, ex.YMax),
arcpy.Point(ex.XMax, ex.YMax),
arcpy.Point(ex.XMax, ex.YMin),
arcpy.Point(ex.XMin, ex.YMin),])
geom = arcpy.Polygon(pts, d.SpatialReference)
if d.SpatialReference != out_sr:
geom = geom.projectAs(out_sr)
cur.insertRow([geom, d.CatalogPath])
示例4: copy_schema
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import CreateFeatureclass_management [as 别名]
def copy_schema(template, new, sr=''):
"""Copy the schema (field definition) of a feature class or a table.
Required:
template -- template table or fc
new -- new output fc or table
Optional:
sr -- spatial reference (only applies if fc) If no sr
is defined, it will default to sr of template.
Example:
>>> copy_schema(r'C:\Temp\soils_city.shp', r'C:\Temp\soils_county.shp')
"""
path, name = os.path.split(new)
desc = arcpy.Describe(template)
ftype = desc.dataType
if 'table' in ftype.lower():
arcpy.CreateTable_management(path, name, template)
else:
stype = desc.shapeType.upper()
sm = 'SAME_AS_TEMPLATE'
if not sr:
sr = desc.spatialReference
arcpy.CreateFeatureclass_management(path, name, stype, template, sm, sm, sr)
return new
示例5: createOutputFC
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import CreateFeatureclass_management [as 别名]
def createOutputFC():
# Input theAOI is the original first parameter (usually CLU feature layer)
#
# Given the path for the new output featureclass, create it as polygon and add required fields
# Later it will be populated using a cursor.
try:
epsgWGS84 = 4326 # EPSG code for: GCS-WGS-1984
outputCS = arcpy.SpatialReference(epsgWGS84)
nasisProjectFC = arcpy.CreateScratchName("nasisProject", workspace=arcpy.env.scratchGDB,data_type="FeatureClass")
# Create empty polygon featureclass with coordinate system that matches AOI.
arcpy.CreateFeatureclass_management(env.scratchGDB, os.path.basename(nasisProjectFC), "POLYGON", "", "DISABLED", "DISABLED", outputCS)
arcpy.AddField_management(nasisProjectFC,"mukey", "TEXT", "", "", "30") # for outputShp
if not arcpy.Exists(nasisProjectFC):
AddMsgAndPrint("\tFailed to create " + nasisProjectFC + " TEMP Layer",2)
return False
return nasisProjectFC
except:
errorMsg()
return False
## ===================================================================================
示例6: createOutputFC
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import CreateFeatureclass_management [as 别名]
def createOutputFC(dictOfFields,preFix="Temp",shape="POLYGON"):
""" This function will creat an empty polygon feature class within the scratch FGDB. The feature class will be in WGS84
and will have have 2 fields created: mukey and mupolygonkey. The feature class name will have a prefix of
'nasisProject.' This feature class is used by the 'requestGeometryByMUKEY' function to write the polygons associated with a NASIS
project.
fieldDict ={field:(fieldType,fieldLength,alias)
fieldDict = {"mukey":("TEXT",30,"Mapunit Key"),"mupolygonkey":("TEXT","",30)}
Return the new feature class including the path. Return False if error ocurred."""
try:
epsgWGS84 = 4326 # EPSG code for: GCS-WGS-1984
outputCS = arcpy.SpatialReference(epsgWGS84)
newFC = arcpy.CreateScratchName(preFix, workspace=arcpy.env.scratchGDB,data_type="FeatureClass")
# Create empty polygon featureclass with coordinate system that matches AOI.
arcpy.CreateFeatureclass_management(env.scratchGDB, os.path.basename(newFC), shape, "", "DISABLED", "DISABLED", outputCS)
for field,params in dictOfFields.iteritems():
try:
fldLength = params[1]
fldAlias = params[2]
except:
fldLength = 0
pass
arcpy.AddField_management(newFC,field,params[0],"#","#",fldLength,fldAlias)
## if len(params[1]) > 0:
## expression = "\"" + params[1] + "\""
## arcpy.CalculateField_management(helYesNo,field,expression,"VB")
## arcpy.AddField_management(nasisProjectFC,"mukey", "TEXT", "", "", "30")
## arcpy.AddField_management(nasisProjectFC,"mupolygonkey", "TEXT", "", "", "30") # for outputShp
if not arcpy.Exists(newFC):
AddMsgAndPrint("\tFailed to create scratch " + newFC + " Feature Class",2)
return False
return newFC
except:
errorMsg()
AddMsgAndPrint("\tFailed to create scratch " + newFC + " Feature Class",2)
return False
## ===================================================================================