本文整理汇总了Python中arcpy.AddWarning方法的典型用法代码示例。如果您正苦于以下问题:Python arcpy.AddWarning方法的具体用法?Python arcpy.AddWarning怎么用?Python arcpy.AddWarning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arcpy
的用法示例。
在下文中一共展示了arcpy.AddWarning方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_TimeOfDay_field_to_sublayer
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddWarning [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
示例2: featuresToGPX
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddWarning [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()
示例3: output_msg
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddWarning [as 别名]
def output_msg(msg, severity=0):
""" Adds a Message (in case this is run as a tool)
and also prints the message to the screen (standard output)
:param msg: text to output
:param severity: 0 = none, 1 = warning, 2 = error
"""
print msg
# Split the message on \n first, so that if it's multiple lines,
# a GPMessage will be added for each line
try:
for string in msg.split('\n'):
# Add appropriate geoprocessing message
if severity == 0:
arcpy.AddMessage(string)
elif severity == 1:
arcpy.AddWarning(string)
elif severity == 2:
arcpy.AddError(string)
except:
pass
示例4: update_package
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddWarning [as 别名]
def update_package(r_library_path=r_lib_path()):
"""Update ArcGIS R bindings on this machine."""
# check that we're in a sane installation environment
validate_environment(overwrite=True)
if r_pkg_version() is None:
arcpy.AddWarning(
"Package is not installed. First use the \"Install R bindings\" script.")
else:
if compare_release_versions():
arcpy.AddMessage("New release detected! Installing.")
install_package(overwrite=True, r_library_path=r_library_path)
else:
msg = "The installed ArcGIS R package (version " + \
"{}) is the current version on GitHub.".format(r_pkg_version())
arcpy.AddMessage(msg)
# execute as standalone script, get parameters from sys.argv
示例5: PrintMsg
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddWarning [as 别名]
def PrintMsg(msg, severity=0):
# Adds tool message to the geoprocessor
#
#Split the message on \n first, so that if it's multiple lines, a GPMessage will be added for each line
try:
for string in msg.split('\n'):
#Add a geoprocessing message (in case this is run as a tool)
if severity == 0:
arcpy.AddMessage(string)
elif severity == 1:
arcpy.AddWarning(string)
elif severity == 2:
arcpy.AddError(" \n" + string)
except:
pass
## ===================================================================================
示例6: PrintMsg
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddWarning [as 别名]
def PrintMsg(msg, severity=0):
# prints message to screen if run as a python script
# Adds tool message to the geoprocessor
#
#Split the message on \n first, so that if it's multiple lines, a GPMessage will be added for each line
try:
for string in msg.split('\n'):
#Add a geoprocessing message (in case this is run as a tool)
if severity == 0:
arcpy.AddMessage(string)
elif severity == 1:
arcpy.AddWarning(string)
elif severity == 2:
arcpy.AddMessage(" ")
arcpy.AddError(string)
#arcpy.AddMessage(" ")
except:
pass
## ===================================================================================
示例7: PrintMsg
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddWarning [as 别名]
def PrintMsg(msg, severity=0):
# prints message to screen if run as a python script
# Adds tool message to the geoprocessor
#
# Split the message on \n first, so that if it's multiple lines, a GPMessage will be added for each line
try:
for string in msg.split('\n'):
#Add a geoprocessing message (in case this is run as a tool)
if severity == 0:
arcpy.AddMessage(string)
elif severity == 1:
arcpy.AddWarning(string)
elif severity == 2:
arcpy.AddMessage(" ")
arcpy.AddError(string)
except:
pass
## ===================================================================================
示例8: PrintMsg
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddWarning [as 别名]
def PrintMsg(msg, severity=0):
# Adds tool message to the geoprocessor
#
#Split the message on \n first, so that if it's multiple lines, a GPMessage will be added for each line
try:
for string in msg.split('\n'):
#Add a geoprocessing message (in case this is run as a tool)
if severity == 0:
arcpy.AddMessage(string)
elif severity == 1:
arcpy.AddWarning(string)
elif severity == 2:
arcpy.AddMessage(" ")
arcpy.AddError(string)
except:
pass
## ===================================================================================
示例9: PrintMsg
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddWarning [as 别名]
def PrintMsg(msg, severity=0):
# prints message to screen if run as a python script
# Adds tool message to the geoprocessor
#
#Split the message on \n first, so that if it's multiple lines, a GPMessage will be added for each line
try:
for string in msg.split('\n'):
#Add a geoprocessing message (in case this is run as a tool)
if severity == 0:
arcpy.AddMessage(string)
elif severity == 1:
arcpy.AddWarning(string)
elif severity == 2:
arcpy.AddMessage(" ")
arcpy.AddError(string)
except:
pass
## ===================================================================================
示例10: AddMsgAndPrint
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddWarning [as 别名]
def AddMsgAndPrint(msg, severity=0):
# prints message to screen if run as a python script
# Adds tool message to the geoprocessor
#
#Split the message on \n first, so that if it's multiple lines, a GPMessage will be added for each line
try:
print msg
#for string in msg.split('\n'):
#Add a geoprocessing message (in case this is run as a tool)
if severity == 0:
arcpy.AddMessage(msg)
elif severity == 1:
arcpy.AddWarning(msg)
elif severity == 2:
arcpy.AddError("\n" + msg)
except:
pass
## ===================================================================================
示例11: AddMsgAndPrint
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddWarning [as 别名]
def AddMsgAndPrint(msg, severity=0):
"""prints messages to screen if the script is executed as
a standalone script. Otherwise, Adds tool message to the
window geoprocessor. Messages are color coded by severity."""
#Split the message on \n first, so that if it's multiple lines, a GPMessage will be added for each line
try:
print msg
#for string in msg.split('\n'):
#Add a geoprocessing message (in case this is run as a tool)
if severity == 0:
arcpy.AddMessage(msg)
elif severity == 1:
arcpy.AddWarning(msg)
elif severity == 2:
arcpy.AddError("\n" + msg)
except:
pass
## ================================================================================================================
示例12: AddMsgAndPrint
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddWarning [as 别名]
def AddMsgAndPrint(msg, severity=0):
# prints message to screen if run as a python script
# Adds tool message to the geoprocessor
#
#Split the message on \n first, so that if it's multiple lines, a GPMessage will be added for each line
try:
#print(msg)
#for string in msg.split('\n'):
#Add a geoprocessing message (in case this is run as a tool)
if severity == 0:
arcpy.AddMessage(msg)
elif severity == 1:
arcpy.AddWarning(msg)
elif severity == 2:
arcpy.AddError("\n" + msg)
except:
pass
## ===================================================================================
示例13: AddMsgAndPrint
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddWarning [as 别名]
def AddMsgAndPrint(msg, severity=0):
# prints message to screen if run as a python script
# Adds tool message to the geoprocessor
#
#Split the message on \n first, so that if it's multiple lines, a GPMessage will be added for each line
try:
#for string in msg.split('\n'):
#Add a geoprocessing message (in case this is run as a tool)
if severity == 0:
arcpy.AddMessage(msg)
elif severity == 1:
arcpy.AddWarning(msg)
elif severity == 2:
arcpy.AddError("\n" + msg)
except:
pass
## ===================================================================================
示例14: AddMsgAndPrint
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddWarning [as 别名]
def AddMsgAndPrint(msg, severity=0):
# prints message to screen if run as a python script
# Adds tool message to the geoprocessor
#
#Split the message on \n first, so that if it's multiple lines, a GPMessage will be added for each line
try:
print msg
#for string in msg.split('\n'):
#Add a geoprocessing message (in case this is run as a tool)
if severity == 0:
arcpy.AddMessage(msg)
elif severity == 1:
arcpy.AddWarning(msg)
elif severity == 2:
arcpy.AddError(msg)
except:
pass
## ===================================================================================