本文整理汇总了Python中arcpy.GetParameterAsText方法的典型用法代码示例。如果您正苦于以下问题:Python arcpy.GetParameterAsText方法的具体用法?Python arcpy.GetParameterAsText怎么用?Python arcpy.GetParameterAsText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arcpy
的用法示例。
在下文中一共展示了arcpy.GetParameterAsText方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parseArguments
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import GetParameterAsText [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
示例2: parseArguments
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import GetParameterAsText [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
示例3: parseArguments
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import GetParameterAsText [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
示例4: main
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import GetParameterAsText [as 别名]
def main():
# Get the value of the input parameter
#
tmpltFolder = arcpy.GetParameterAsText(0)
# When empty, it falls back to the default template location like ExportWebMap tool does
#
if (len(tmpltFolder) == 0):
tmpltFolder = _defTmpltFolder
# Getting a list of all file paths with .mxd extensions
# createing MapDocument objects and putting them in an array
#
mxds = []
for f in glob.glob(os.path.join(tmpltFolder, "*.mxd")):
try: #throw exception when MapDocument is corrupted
mxds.append(arcpy.mapping.MapDocument(f))
except:
arcpy.AddWarning("Unable to open map document named {0}".format(os.path.basename(f)))
# Encoding the array of MapDocument to JSON using a custom JSONEncoder class
#
outJSON = json.dumps(mxds, cls=MxdEncoder, indent=2)
# Set output parameter
#
arcpy.SetParameterAsText(1, outJSON)
# Clean up
#
del mxds
示例5: fixArgs
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import GetParameterAsText [as 别名]
def fixArgs(arg, arg_type=list):
"""Fixe arguments from a script tool.
For example, when using a script tool with a multivalue parameter,
it comes in as "val_a;val_b;val_c". This function can automatically
fix arguments based on the arg_type.
Another example is the boolean type returned from a script tool -
instead of True and False, it is returned as "true" and "false".
Required:
arg -- argument from script tool (arcpy.GetParameterAsText() or sys.argv[1]) (str)
arg_type -- type to convert argument from script tool parameter. Default is list.
Example:
>>> # example of list returned from script tool multiparameter argument
>>> arg = "val_a;val_b;val_c"
>>> fixArgs(arg, list)
['val_a', 'val_b', 'val_c']
"""
if arg_type == list:
if isinstance(arg, str):
# need to replace extra quotes for paths with spaces
# or anything else that has a space in it
return map(lambda a: a.replace("';'",";"), arg.split(';'))
else:
return list(arg)
if arg_type == float:
if arg != '#':
return float(arg)
else:
return ''
if arg_type == int:
return int(arg)
if arg_type == bool:
if str(arg).lower() == 'true' or arg == 1:
return True
else:
return False
if arg_type == str:
if arg in [None, '', '#']:
return ''
return arg
示例6: main
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import GetParameterAsText [as 别名]
def main():
xml_file = arcpy.GetParameterAsText(1)
input_workspace = arcpy.GetParameterAsText(0)
field = arcpy.GetParameterAsText(2)
checked = []
fcs = get_fcs(input_workspace)
xmldoc = minidom.parse(xml_file)
value_list = xmldoc.getElementsByTagName('Expression')
fc_list = xmldoc.getElementsByTagName('FeatureClass')
where_list = xmldoc.getElementsByTagName('WhereClause')
## print(len(value_list))
## print(len(fc_list))
## print(len(where_list))
for index, fc_item in enumerate(fc_list):
fc = fc_item.firstChild.data
where_item = where_list[index]
where = where_item.firstChild.data
value_item = value_list[index]
value_str = value_item.firstChild.data
string_list = str(value_str).split("Generate = ")
value = string_list[1][:1]
value = int(value)
if fc in fcs:
update_fc = fcs[str(fc)]
print update_fc
if update_fc not in checked:
check_field(update_fc, field)
checked.append(update_fc)
print("updating " + str(fc) + " where " + str(where) )
up_cnt = 0
with arcpy.da.UpdateCursor(update_fc, '*', where) as cursor:
cfields = cursor.fields
field_ind = 0
for index, item in enumerate(cfields):
if item == field:
field_ind = index
if field_ind >= 0:
for row in cursor:
row[field_ind] = value
cursor.updateRow(row)
up_cnt += 1
arcpy.AddMessage(str(up_cnt) + " features updated in " + str(fc) + " where " + str(where))
pass