本文整理汇总了Python中arcpy.AddMessage方法的典型用法代码示例。如果您正苦于以下问题:Python arcpy.AddMessage方法的具体用法?Python arcpy.AddMessage怎么用?Python arcpy.AddMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arcpy
的用法示例。
在下文中一共展示了arcpy.AddMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createUniqueIDTable
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddMessage [as 别名]
def createUniqueIDTable(self, in_nc, out_table):
"""Create a table of unique stream IDs"""
data_nc = NET.Dataset(in_nc)
comid_arr = data_nc.variables[self.vars_oi[0]][:]
comid_size = len(comid_arr)
comid_arr = comid_arr.reshape(comid_size, 1)
arcpy.AddMessage(comid_arr.transpose())
arcpy.AddMessage(self.vars_oi[0])
#convert to numpy structured array
str_arr = NUM.core.records.fromarrays(comid_arr.transpose(), NUM.dtype([(self.vars_oi[0], NUM.int32)]))
# numpy structured array to table
arcpy.da.NumPyArrayToTable(str_arr, out_table)
data_nc.close()
return
示例2: calculateTimeField
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddMessage [as 别名]
def calculateTimeField(self, out_table, start_datetime, time_interval):
"""Add & calculate TimeValue field: scripts adapted from TimeTools.pyt developed by N. Noman"""
timeIndexFieldName = self.fields_oi[0]
timeValueFieldName = self.fields_oi[3]
#Add TimeValue field
arcpy.AddField_management(out_table, timeValueFieldName, "DATE", "", "", "", timeValueFieldName, "NULLABLE")
#Calculate TimeValue field
expression = "CalcTimeValue(!" + timeIndexFieldName + "!, '" + start_datetime + "', " + time_interval + ")"
codeBlock = """def CalcTimeValue(timestep, sdatestr, dt):
if (":" in sdatestr):
sdate = datetime.datetime.strptime(sdatestr, '%m/%d/%Y %I:%M:%S %p')
else:
sdate = datetime.datetime.strptime(sdatestr, '%m/%d/%Y')
tv = sdate + datetime.timedelta(hours=(timestep - 1) * dt)
return tv"""
arcpy.AddMessage("Calculating " + timeValueFieldName + "...")
arcpy.CalculateField_management(out_table, timeValueFieldName, expression, "PYTHON_9.3", codeBlock)
return
示例3: get_stop_lat_lon
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddMessage [as 别名]
def get_stop_lat_lon():
'''Populate a dictionary of {stop_id: [stop_lat, stop_lon]}'''
arcpy.AddMessage("Collecting and processing GTFS stop information...")
# Find all stops with lat/lon
global stoplatlon_dict
stoplatlon_dict = {}
cs = conn.cursor()
stoplatlonfetch = '''
SELECT stop_id, stop_lat, stop_lon FROM stops
;'''
cs.execute(stoplatlonfetch)
for stop in cs:
# Add stop lat/lon to dictionary
stoplatlon_dict[stop[0]] = [stop[1], stop[2]]
示例4: HandleOIDUniqueID
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddMessage [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
示例5: getAOI
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddMessage [as 别名]
def getAOI(prod_db):
# Set workspace
arcpy.env.workspace = prod_db
# Get MetaDataA fc
meta_fc = getFC(prod_db, "MetaDataA", NAUT_FDS)
if meta_fc:
# Make feature layer where FCSUBTYPE = M_NSYS
where = "FCSUBTYPE = 35"
arcpy.MakeFeatureLayer_management(meta_fc, "meta_lyr", where)
# Dissolve layer into one feature
arcpy.AddMessage("\tDissolving area of interest into one feature")
aoi = "in_memory\\aoi"
arcpy.Dissolve_management("meta_lyr", aoi, multi_part="SINGLE_PART")
arcpy.MakeFeatureLayer_management(aoi, "aoi")
return "aoi"
else:
raise ex("MetaDataA feature class not found in " + prod_db)
示例6: output_msg
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddMessage [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
示例7: update_package
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddMessage [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
示例8: updateOverrides
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddMessage [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: calcRadiance
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddMessage [as 别名]
def calcRadiance (LMAX, LMIN, QCALMAX, QCALMIN, QCAL, band):
LMAX = float(LMAX)
LMIN = float(LMIN)
QCALMAX = float(QCALMAX)
QCALMIN = float(QCALMIN)
offset = (LMAX - LMIN)/(QCALMAX-QCALMIN)
inraster = Raster(QCAL)
outname = 'RadianceB'+str(band)+'.tif'
arcpy.AddMessage('Band'+str(band))
arcpy.AddMessage('LMAX ='+str(LMAX))
arcpy.AddMessage('LMIN ='+str(LMIN))
arcpy.AddMessage('QCALMAX ='+str(QCALMAX))
arcpy.AddMessage('QCALMIN ='+str(QCALMIN))
arcpy.AddMessage('offset ='+str(offset))
outraster = (offset * (inraster-QCALMIN)) + LMIN
outraster.save(outname)
return outname
示例10: parseArguments
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddMessage [as 别名]
def parseArguments():
parser = argparse.ArgumentParser(
usage='Add/Update GNSS metadate fields')
arcpy.AddMessage("Parsing Arguments..")
parser.add_argument('url', help='Organization url')
parser.add_argument('username', help='Organization username')
parser.add_argument('password', help='Organization password')
parser.add_argument('itemId', type=str, help='Feature service Item Id')
parser.add_argument('layerIndex', type=int, help='Feature Layer index. If not specified use 0 as index')
parser.add_argument('-r', dest='remove', default=False, type=bool,
help='Set True if GNSS metadata fields need to be removed')
args_parser = parser.parse_args()
if '*' in args_parser.password:
args_parser.password = password = arcpy.GetParameterAsText(2)
arcpy.AddMessage("Done parsing arguments..")
return args_parser
# Search for a item id and add GNSS Metadata fields
示例11: update_feature_service
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddMessage [as 别名]
def update_feature_service(itemId,owner,folder_id,gis,feaureService_data):
params = {
"token": gis._con.token,
"text": json.dumps(feaureService_data).encode('utf8', errors='replace'),
"f": "json"
}
if folder_id and folder_id != "":
featureServiceItem_Url = "{}/sharing/rest/content/users/{}/{}/items/{}/update".format(args_parser.url,owner,folder_id, itemId)
else:
featureServiceItem_Url = "{}/sharing/rest/content/users/{}/items/{}/update".format(args_parser.url,owner, itemId)
updateResponse = urllib.request.urlopen(featureServiceItem_Url,bytes(urllib.parse.urlencode(params),'utf-8')).read()
result = json.loads(updateResponse.decode("utf-8"))
if 'error' in result.keys():
ex = result['error']['message']
arcpy.AddMessage("Error..{}".format(ex))
else:
arcpy.AddMessage("Successfully configured popup and visibility on the Feature service Item..")
# Parse Command-line arguments
示例12: parseArguments
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddMessage [as 别名]
def parseArguments():
parser = argparse.ArgumentParser(
usage='Configure GNSS metadate fields visibility and popup')
arcpy.AddMessage("Parsing Arguments..")
parser.add_argument('url', help='Organization url')
parser.add_argument('username', help='Organization username')
parser.add_argument('password', help='Organization password')
parser.add_argument('webmap_Name', type=str, help='Webmap Name')
parser.add_argument('layerIndex', type=int, help='Feature Layer index. If not specified use 0 as index')
args_parser = parser.parse_args()
if '*' in args_parser.password:
args_parser.password = password = arcpy.GetParameterAsText(2)
arcpy.AddMessage("Done parsing arguments..")
return args_parser
# Search for a Webmap and update GNSS Metadata fields popup info
示例13: parseArguments
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddMessage [as 别名]
def parseArguments():
parser = argparse.ArgumentParser(
usage='Reset required fields to None in the feature templates')
arcpy.AddMessage("Parsing Arguments..")
parser.add_argument('url', help='Organization url')
parser.add_argument('username', help='Organization username')
parser.add_argument('password', help='Organization password')
parser.add_argument('itemId', type=str, help='Feature service Item Id')
args_parser = parser.parse_args()
if '*' in args_parser.password:
args_parser.password = password = arcpy.GetParameterAsText(2)
arcpy.AddMessage("Done parsing arguments..")
return args_parser
示例14: PrintMsg
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddMessage [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
## ===================================================================================
示例15: PrintMsg
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddMessage [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
## ===================================================================================