本文整理汇总了Python中arcpy.Describe方法的典型用法代码示例。如果您正苦于以下问题:Python arcpy.Describe方法的具体用法?Python arcpy.Describe怎么用?Python arcpy.Describe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arcpy
的用法示例。
在下文中一共展示了arcpy.Describe方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: updateParameters
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import Describe [as 别名]
def updateParameters(self, parameters):
params=parameters
# if parameters[0].altered and not parameters[1].altered:
# parameters[1].value=arcpy.Describe(parameters[0].valueAsText).OIDFieldName
if params[4].value=='CUT_OFF':
params[5].enabled=1
params[6].enabled=0
else:
params[5].enabled=0
params[6].enabled=1
if params[7].value=='CPU':
params[8].enabled=1
else:
params[8].enabled=0
if parameters[0].altered and not parameters[3].altered:
in_fe=parameters[0].valueAsText
parameters[3].value=in_fe[:len(in_fe)-4]+'_dens'+in_fe[-4:] if in_fe[-3:]=='shp' else in_fe+'_dens'
return
示例2: generate_cls_boundary
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import Describe [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
示例3: HandleOIDUniqueID
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import Describe [as 别名]
def HandleOIDUniqueID(inPointsLayer, inLocUniqueID):
'''If ObjectID was selected as the unique ID, copy the values to a new field
so they don't get messed up when copying the table.'''
pointsOID = arcpy.Describe(inPointsLayer).OIDFieldName
if inLocUniqueID.lower() == pointsOID.lower():
try:
inLocUniqueID = "BBBUID"
arcpy.AddMessage("You have selected your input features' ObjectID field as the unique ID to use for this analysis. \
In order to use this field, we have to transfer the ObjectID values to a new field in your input data called '%s' because ObjectID values \
may change when the input data is copied to the output. Adding the '%s' field now, and calculating the values to be the same as the current \
ObjectID values..." % (inLocUniqueID, inLocUniqueID))
arcpy.management.AddField(inPointsLayer, inLocUniqueID, "LONG")
arcpy.management.CalculateField(inPointsLayer, inLocUniqueID, "!" + pointsOID + "!", "PYTHON_9.3")
except:
arcpy.AddError("Unable to add or calculate new unique ID field. Please fix your data or choose a different unique ID field.")
raise CustomError
return inLocUniqueID
示例4: add_TimeOfDay_field_to_sublayer
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import Describe [as 别名]
def add_TimeOfDay_field_to_sublayer(nalayer, sublayer_object, sublayer_name):
'''Add a field called TimeOfDay of type DATE to an NA sublayer'''
time_field = "TimeOfDay"
# Clean up any pre-existing fields with this name (unlikely case)
poly_fields = [f for f in arcpy.Describe(sublayer_object).fields if f.name == time_field]
if poly_fields:
for f in poly_fields:
if f.name == time_field and f.type != "Date":
msg = "Your network analysis layer's %s sublayer already contained a field called %s of a type " + \
"other than Date. This field will be deleted and replaced with a field of type Date used " + \
"for the output of this tool."
arcpy.AddWarning(msg % (sublayer_name, time_field))
arcpy.management.DeleteField(sublayer_object, time_field)
# Add the TimeOfDay field to the sublayer. If it already exists, this will do nothing.
arcpy.na.AddFieldToAnalysisLayer(nalayer, sublayer_name, time_field, "DATE")
return time_field
示例5: featuresToGPX
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import Describe [as 别名]
def featuresToGPX(inputFC, outGPX, zerodate, pretty):
''' This is called by the __main__ if run from a tool or at the command line
'''
descInput = arcpy.Describe(inputFC)
if descInput.spatialReference.factoryCode != 4326:
arcpy.AddWarning("Input data is not projected in WGS84,"
" features were reprojected on the fly to create the GPX.")
generatePointsFromFeatures(inputFC , descInput, zerodate)
# Write the output GPX file
try:
if pretty:
gpxFile = open(outGPX, "w")
gpxFile.write(prettify(gpx))
else:
gpxFile = open(outGPX, "wb")
ET.ElementTree(gpx).write(gpxFile, encoding="UTF-8", xml_declaration=True)
except TypeError as e:
arcpy.AddError("Error serializing GPX into the file.")
finally:
gpxFile.close()
示例6: check_prop_list
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import Describe [as 别名]
def check_prop_list(user_types):
""" Verify that the user has entered valid Describe Object types/classes and
print a warning message for any invalid choices. If no arguments are
provided, the report will print all Describe properties.Returns a list
of Describe properties whose attributes will be included in the report.
"""
if not user_types:
queried_types = [p for p in properties]
else:
invalid_types = list()
queried_types = list()
[queried_types.append(k) if k in properties else invalid_types.append(k) for k in user_types]
if invalid_types:
print("WARNING! Describe Types will not be included in report:")
for t in invalid_types:
print(t)
return queried_types
示例7: make_poly_from_extent
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import Describe [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)
示例8: updateOverrides
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import Describe [as 别名]
def updateOverrides(fcs):
""" loops through all feature classes and applies overrides to the geometry"""
for fc in fcs:
arcpy.env.overwriteOutput = True
arcpy.env.addOutputsToMap = False
desc = arcpy.Describe(fc)
rep_name = ""
if hasattr(desc, "representations"):
reps = desc.representations
for rep in reps:
rep_name = rep.name
arcpy.AddMessage("Applying Rep Overrides for " + str(fc))
arcpy.UpdateOverride_cartography(fc, rep_name, "BOTH")
arcpy.AddMessage("Repairing Geometry for " + str(fc))
arcpy.RepairGeometry_management(fc)
return fcs
示例9: form_connection_string
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import Describe [as 别名]
def form_connection_string(ws):
"""Esri's describe workspace connection string does not work at 10.4, bug???"""
desc = arcpy.Describe(ws)
if 'SdeWorkspaceFactory' in desc.workspaceFactoryProgID:
cp = desc.connectionProperties
props = ['server', 'instance', 'database', 'version', 'authentication_mode']
db_client = cp.instance.split(':')[1]
con_properties = cp.server
parts = []
for prop in props:
parts.append('{}={}'.format(prop.upper(), getattr(cp, prop)))
parts.insert(2, 'DBCLIENT={}'.format(db_client))
parts.insert(3, 'DB_CONNECTION_PROPERTIES={}'.format(cp.server))
return ';'.join(parts)
else:
return 'DATABASE=' + ws
示例10: __init__
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import Describe [as 别名]
def __init__(self, path):
"""Initialize `arcpy.Describe` object with basic properties."""
self.path = path
self._desc = arcpy.Describe(self.path)
self.catalogPath = self._desc.catalogPath
self.name = self._desc.name
self.root = os.path.dirname(self.catalogPath)
if hasattr(arcpy.Describe(self.root),
'datasetType'): # 'FeatureDataset':
self.wkspc = os.path.dirname(self.root)
else: # FeatureClass
self.wkspc = self.root
if 'Remote' in arcpy.Describe(self.wkspc).workspaceType:
self.name = '.'.join(self.name.split('.')[1:])
########################################################################
示例11: get_attachments_count
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import Describe [as 别名]
def get_attachments_count(self):
"""Get number of attachments stored for a table/feature class."""
rel_classes = [
os.path.join(self.root, rc)
for rc in getattr(self._desc, 'relationshipClassNames', [''])
]
for rc in rel_classes:
rc_desc = arcpy.Describe(rc)
if rc_desc.isAttachmentRelationship:
return int(
arcpy.GetCount_management(
os.path.join(
self.root,
rc_desc.destinationClassNames[0])).getOutput(0))
# ----------------------------------------------------------------------
示例12: CheckSpatialReference
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import Describe [as 别名]
def CheckSpatialReference(inputFC):
# Make sure that the coordinate system is projected and units are meters
try:
desc = arcpy.Describe(inputFC)
inputSR = desc.spatialReference
if inputSR.type.upper() == "PROJECTED":
if inputSR.linearUnitName.upper() == "METER":
env.outputCoordinateSystem = inputSR
return True
else:
raise MyError, os.path.basename(theGDB) + ": Input soil polygon layer does not have a valid coordinate system for gSSURGO"
else:
raise MyError, os.path.basename(theGDB) + ": Input soil polygon layer must have a projected coordinate system"
except MyError, e:
# Example: raise MyError, "This is an error message"
PrintMsg(str(e), 2)
return False
示例13: GetWorkspace
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import Describe [as 别名]
def GetWorkspace(ssurgoInput):
# Return the workspace of the input
""" Maybe get rid of this or add it to the main body """
try:
desc = arcpy.Describe(ssurgoInput)
thePath = os.path.dirname(desc.CatalogPath)
desc = arcpy.Describe(thePath)
# if path to ssurgoInput is a FD grab the GDB path
if desc.dataType.upper() == "FEATUREDATASET":
thePath = os.path.dirname(thePath)
env.workspace = thePath
return thePath
except:
errorMsg()
## ===================================================================================
示例14: updateParameters
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import Describe [as 别名]
def updateParameters(self, parameters):
# if parameters[0].altered and not parameters[2].altered:
# parameters[2].value=arcpy.Describe(parameters[0].valueAsText).OIDFieldName
if parameters[0].altered and not parameters[5].altered:
in_fe=parameters[0].valueAsText
parameters[5].value=in_fe[:len(in_fe)-4]+'_filter'+in_fe[-4:] if in_fe[-3:]=='shp' else in_fe+'_filter'
return
示例15: updateParameters
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import Describe [as 别名]
def updateParameters(self, parameters):
# if parameters[0].altered and not parameters[1].altered:
# parameters[1].value=arcpy.Describe(parameters[0].valueAsText).OIDFieldName
if (parameters[0].altered or parameters[4].altered) and not parameters[5].altered:#parameters[5].valueAsText==self.cntr_addr:
in_fe=parameters[0].valueAsText
cntrnum=parameters[4].value
self.cntr_addr=parameters[5].value=in_fe[:len(in_fe)-4]+'_%dcntr'%cntrnum+in_fe[-4:] if in_fe[-3:]=='shp' else in_fe+'_%dcntr'%cntrnum
if (parameters[0].altered or parameters[4].altered) and not parameters[6].altered:#parameters[6].valueAsText==self.cls_addr:
in_fe=parameters[0].valueAsText
cntrnum=parameters[4].value
self.cls_addr=parameters[6].value=in_fe[:len(in_fe)-4]+'_%dcntr_cls'%cntrnum+in_fe[-4:] if in_fe[-3:]=='shp' else in_fe+'_%dcntr_cls'%cntrnum
return