當前位置: 首頁>>代碼示例>>Python>>正文


Python arcpy.GetParameterAsText方法代碼示例

本文整理匯總了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 
開發者ID:Esri,項目名稱:collector-tools,代碼行數:24,代碼來源:add_update_gnss_fields_python_api.py

示例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 
開發者ID:Esri,項目名稱:collector-tools,代碼行數:22,代碼來源:configure_gnss_popup_python_api.py

示例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 
開發者ID:Esri,項目名稱:collector-tools,代碼行數:20,代碼來源:reset_required_fields_python_api.py

示例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 
開發者ID:arcpy,項目名稱:sample-gp-tools,代碼行數:34,代碼來源:GetLayoutTemplatesInfo.py

示例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 
開發者ID:NERC-CEH,項目名稱:arcapi,代碼行數:44,代碼來源:arcapi.py

示例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 
開發者ID:Esri,項目名稱:CTM,代碼行數:53,代碼來源:parseVST.py


注:本文中的arcpy.GetParameterAsText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。