• arcgis 获得路径和环境变量信息


    import arcpy

    import sys
    import os
    import string

    reload(sys)
    sys.setdefaultencoding("utf8")
    scratchWS = arcpy.env.scratchWorkspace
    arcpy.AddMessage("默认地理数据库路径:" + scratchWS)
    scriptPath      = sys.path[0];
    arcpy.AddMessage("系统路径:" + scriptPath)
    toolSharePath   = os.path.dirname(scriptPath)
    arcpy.AddMessage("路径:" + toolSharePath)
    scratchWS = arcpy.GetSystemEnvironment("TEMP")
    arcpy.AddMessage("临时:" + toolSharePath)
    arcpy.AddMessage(arcpy.GetMessages())


    environments = arcpy.ListEnvironments()

    ########################################################
    #
    environments.sort(key=string.lower)

    for environment in environments:
        # As the environment is passed as a variable, use Python's getattr
        #   to evaluate the environment's value
        #
        envSetting = getattr(arcpy.env, environment)

        # Format and print each environment and its current setting
        #
        arcpy.AddMessage( "{0:<30}: {1}".format(environment, envSetting))

    结果:

    默认地理数据库路径:C:UsersAdministratorDocumentsArcGISDefault.gdb
    系统路径:D:
    路径:D:
    临时:D:
    autoCommit                    : 1000
    cartographicCoordinateSystem  : None
    cellSize                      : MAXOF
    coincidentPoints              : MEAN
    compression                   : LZ77
    configKeyword                 : None
    derivedPrecision              : HIGHEST
    extent                        : None
    geographicTransformations     : None
    maintainSpatialIndex          : False
    mask                          : None
    MDomain                       : None
    MResolution                   : None
    MTolerance                    : None
    newPrecision                  : SINGLE
    outputCoordinateSystem        : None
    outputMFlag                   : Same As Input
    outputZFlag                   : Same As Input
    outputZValue                  : None
    projectCompare                : NONE
    pyramid                       : PYRAMIDS -1 NEAREST DEFAULT 75
    qualifiedFieldNames           : True
    randomGenerator               : 0 ACM599
    rasterStatistics              : STATISTICS 1 1
    referenceScale                : None
    scratchWorkspace              : C:UsersAdministratorDocumentsArcGISDefault.gdb
    snapRaster                    : None
    spatialGrid1                  : 0.0
    spatialGrid2                  : 0.0
    spatialGrid3                  : 0.0
    terrainMemoryUsage            : False
    tileSize                      : 128 128
    tinSaveVersion                : CURRENT
    workspace                     : C:UsersAdministratorDocumentsArcGISDefault.gdb
    XYDomain                      : None
    XYResolution                  : None
    XYTolerance                   : None
    ZDomain                       : None
    ZResolution                   : None
    ZTolerance                    : None
    Completed script 脚本...
    成功 在 Sat Nov 16 08:28:26 2013 (经历的时间: 1.00 秒)

    =================================================

    #########################
    import arcpy

    import os
    import sys

    #################################
    #
    scriptPath = sys.path[0]
    arcpy.AddMessage("Script folder: " + scriptPath)

    toolSharePath = os.path.dirname(scriptPath)

    num=len(sys.path)
    for i in range(num):
    scriptPath = sys.path[i]

    arcpy.AddMessage("Script folder: " + scriptPath+":"+str(i))

    结果如下:

    消息
    执行: 导入工具箱 #
    开始时间: Fri Jul 19 13:49:41 2019
    正在运行脚本 导入工具箱...
    Script folder: F: knew106 ool
    ToolShare folder: F: knew106
    Script folder: C:WINDOWSSYSTEM32python26.zip
    Script folder: C:Program Files (x86)ArcGISDesktop10.0arcpy
    Script folder: C:Python26ArcGIS10.0Lib
    Script folder: C:Python26ArcGIS10.0DLLs
    Script folder: C:Python26ArcGIS10.0Liblib-tk
    Script folder: C:Program Files (x86)ArcGISDesktop10.0Bin
    Script folder: F: knew106 ool:0
    Script folder: C:WINDOWSSYSTEM32python26.zip:1
    Script folder: C:Program Files (x86)ArcGISDesktop10.0arcpy:2
    Script folder: C:Python26ArcGIS10.0Lib:3
    Script folder: C:Python26ArcGIS10.0DLLs:4
    Script folder: C:Python26ArcGIS10.0Liblib-tk:5
    Script folder: C:Program Files (x86)ArcGISDesktop10.0Bin:6
    Script folder: C:Python26ArcGIS10.0:7
    Script folder: C:Python26ArcGIS10.0libsite-packages:8
    Script folder: C:Program Files (x86)ArcGISDesktop10.0arcpy:9
    Script folder: C:Program Files (x86)ArcGISDesktop10.0ArcToolboxScripts:10
    Script folder: C:Python26ArcGIS10.0libsite-packageswin32:11
    Script folder: C:Python26ArcGIS10.0libsite-packageswin32lib:12
    Script folder: C:Python26ArcGIS10.0libsite-packagesPythonwin:13
    Completed script 导入工具箱...
    成功 在 Fri Jul 19 13:49:41 2019 (经历的时间: 0.00 秒)

     

  • 相关阅读:
    Google基本利用
    sqlmap
    kali中wireshark打开后错误
    Python Flask Jinja2模板引擎
    Python Flask学习
    Python 豆瓣日记爬取
    Python 函数装饰器
    Python 生成器
    ss源码学习--从协议建立到完成一次代理请求
    ss源码学习--工作流程
  • 原文地址:https://www.cnblogs.com/gisoracle/p/3394051.html
Copyright © 2020-2023  润新知