Skip to content
The Chat Archive
gpt-3.5-turbo-0613· OpenAI WildChat-4.8M (AI2)

PS F:\tif> & D:/arcgis10.5/ArcGIS10.5/python.exe f:/tif/py/maskby.py WARNING: Unable to…

  1. User

    PS F:\tif> & D:/arcgis10.5/ArcGIS10.5/python.exe f:/tif/py/maskby.py WARNING: Unable to load code page translation table d:\arcgis10.5\desktop10.5\locale\codepage\936.txt. WARNING: Unable to load code page translation table d:\arcgis10.5\desktop10.5\locale\codepage\936.txt. Code page conversion is off for writing data into files. Code page conversion is off for writing data into files. WARNING: Unable to load code page translation table d:\arcgis10.5\desktop10.5\locale\codepage\936.txt. WARNING: Unable to load code page translation table d:\arcgis10.5\desktop10.5\locale\codepage\936.txt. Code page conversion is off for reading data from files. Code page conversion is off for reading data from files. Traceback (most recent call last): File "f:/tif/py/maskby.py", line 42, in out_extract = ExtractByMask(ras, mask) # 鎵ц鎸夋帺妯℃彁鍙栨搷浣? File "D:\arcgis10.5\Desktop10.5\ArcPy\arcpy\sa\Functions.py", line 7201, in ExtractByMask in_mask_data) File "D:\arcgis10.5\Desktop10.5\ArcPy\arcpy\sa\Utils.py", line 53, in swapper
    result = wrapper(*args, **kwargs) File "D:\arcgis10.5\Desktop10.5\ArcPy\arcpy\sa\Functions.py", line 7197, in Wrapper out_raster) File "D:\arcgis10.5\Desktop10.5\ArcPy\arcpy\geoprocessing_base.py", line 510, in return lambda *args: val(*gp_fixargs(args, True)) arcgisscripting.ExecuteError: ERROR 999999: Error executing function. Failed to execute (ExtractByMask).

  2. Assistant

    The error message suggests that there was an issue executing the ExtractByMask function in the maskby.py script. It is likely that there is a problem with the input parameters or the file paths.

    Here are a few things you can try to resolve the issue:

    1. Verify that the file paths for the raster dataset and mask dataset are correct. Make sure that the files exist in the specified locations.

    2. Check the file permissions for both the raster dataset and mask dataset. Ensure that the user running the script has sufficient privileges to read the input files and write the output files.

    3. Make sure that the raster dataset and mask dataset are in a compatible format. Check the documentation for the ExtractByMask function to see the supported raster formats.

    4. Ensure that the ArcGIS version specified in the script (ArcGIS 10.5 in this case) is compatible with the version installed on the system. If you are using a different version of ArcGIS, update the paths accordingly.

    If none of these suggestions resolve the issue, it may be helpful to provide more information about the specific datasets and the code you are using.

  3. User

    PS F:\tif> & D:/arcgis10.5/ArcGIS10.5/python.exe f:/tif/py/maskby.py WARNING: Unable to load code page translation table d:\arcgis10.5\desktop10.5\locale\codepage\936.txt. WARNING: Unable to load code page translation table d:\arcgis10.5\desktop10.5\locale\codepage\936.txt. Code page conversion is off for writing data into files. Code page conversion is off for writing data into files. WARNING: Unable to load code page translation table d:\arcgis10.5\desktop10.5\locale\codepage\936.txt. WARNING: Unable to load code page translation table d:\arcgis10.5\desktop10.5\locale\codepage\936.txt. Code page conversion is off for reading data from files. Code page conversion is off for reading data from files. Traceback (most recent call last): File "f:/tif/py/maskby.py", line 42, in out_extract = ExtractByMask(ras, mask) # 鎵ц鎸夋帺妯℃彁鍙栨搷浣? File "D:\arcgis10.5\Desktop10.5\ArcPy\arcpy\sa\Functions.py", line 7201, in ExtractByMask in_mask_data) File "D:\arcgis10.5\Desktop10.5\ArcPy\arcpy\sa\Utils.py", line 53, in swapper
    result = wrapper(*args, **kwargs) File "D:\arcgis10.5\Desktop10.5\ArcPy\arcpy\sa\Functions.py", line 7197, in Wrapper out_raster) File "D:\arcgis10.5\Desktop10.5\ArcPy\arcpy\geoprocessing_base.py", line 510, in return lambda *args: val(*gp_fixargs(args, True)) arcgisscripting.ExecuteError: ERROR 999999: Error executing function. Failed to execute (ExtractByMask).怎么解决

  4. Assistant

    你的问题提示中显示了一些警告和错误,但是信息不足以确定问题的具体原因。我建议你尝试以下几个解决方案:

    1. 确保你的代码中指定的文件路径是正确的,并且输入的栅格数据集和掩膜数据集在指定的位置存在。

    2. 检查栅格数据集和掩膜数据集的文件权限,确保运行脚本的用户有足够的权限来读取输入文件并写入输出文件。

    3. 确保栅格数据集和掩膜数据集具有兼容的格式。查看ExtractByMask函数的文档,了解支持的栅格格式。

    4. 确认脚本中指定的ArcGIS版本(此处为ArcGIS 10.5)与系统中安装的版本兼容。如果你使用的是不同版本的ArcGIS,请相应地更新路径。

    另外,请尽可能提供更多关于数据集和代码的详细信息,这样我才能更好地帮助你解决问题。

  5. User

    -- coding: UTF-8 --

    import arcpy from arcpy import env from arcpy.sa import * import glob import os

    '''

    批量裁剪:

    对输入文件夹下的数据,根据 shp 文件,进行批量裁剪,结果存放于输出文件夹

    需要修改:

    inws:输入路径(必选)

    outws:输出路径(必选)

    mask:参考范围的 shp 文件(必选)

    nameT:建议进行规范化,文件名的易读性(可选)

    '''

    arcpy.CheckOutExtension('Spatial')

    env.workspace = r"F:\tif\wushenqi"

    输入路径 应该注意,中文路径,会导致读不出文件

    inws = (r"F:\tif\wushenqi\tif\vci_drought\nwushenqi_vci3-20230817T062019Z-001\nwushenqi_vci3")

    输出路径

    outws = (r"F:\tif\wushenqi\data\wushenqi_3\vci")

    指定 shp 范围边界文件,即目标区域的边界

    mask = (r"F:\tif\wushenqi\shp\split\wushenqi_3\7599.shp")

    利用 glob 包,将 inws 下的所有 tif 文件读存放到 rasters 中

    rasters = glob.glob(os.path.join(inws, "*.tif"))

    循环 rasters 中的所有影像,进行按掩模提取操作

    for ras in rasters: # nameT:输出文件名

    nameT = os.path.basename(ras) + "_clp.tif"
    
    outname = os.path.join(outws, nameT)  # 合并输出文件名 + 输出路径
    out_extract = ExtractByMask(ras, mask)  # 执行按掩模提取操作
    out_extract.save(outname)  # 保存数据
    

    PS F:\tif> & D:/arcgis10.5/ArcGIS10.5/python.exe f:/tif/py/maskby.py WARNING: Unable to load code page translation table d:\arcgis10.5\desktop10.5\locale\codepage\936.txt. WARNING: Unable to load code page translation table d:\arcgis10.5\desktop10.5\locale\codepage\936.txt. Code page conversion is off for writing data into files. Code page conversion is off for writing data into files. WARNING: Unable to load code page translation table d:\arcgis10.5\desktop10.5\locale\codepage\936.txt. WARNING: Unable to load code page translation table d:\arcgis10.5\desktop10.5\locale\codepage\936.txt. Code page conversion is off for reading data from files. Code page conversion is off for reading data from files. Traceback (most recent call last): File “f:/tif/py/maskby.py”, line 42, in out_extract = ExtractByMask(ras, mask) # 鎵ц鎸夋帺妯℃彁鍙栨搷浣? File “D:\arcgis10.5\Desktop10.5\ArcPy\arcpy\sa\Functions.py”, line 7201, in ExtractByMask in_mask_data) File “D:\arcgis10.5\Desktop10.5\ArcPy\arcpy\sa\Utils.py”, line 53, in swapper result = wrapper(*args, **kwargs) File “D:\arcgis10.5\Desktop10.5\ArcPy\arcpy\sa\Functions.py”, line 7197, in Wrapper out_raster) File “D:\arcgis10.5\Desktop10.5\ArcPy\arcpy\geoprocessing_base.py”, line 510, in return lambda *args: val(*gp_fixargs(args, True)) arcgisscripting.ExecuteError: ERROR 999999: Error executing function. Failed to execute (ExtractByMask).怎么解决 print os.path.basename(ras) + " ---- down" print " ---- down ---- "

  6. Assistant

    根据提供的代码和错误信息,问题可能出在以下几个方面:

    1. 中文路径问题:尽量避免在代码中使用中文路径,因为它可能导致文件读取错误。请确保输入路径和输出路径以及 shp 路径都是合法的英文路径。

    2. shp 文件问题:检查指定的 shp 文件路径是否正确,并确保它是一个有效的矢量边界文件。你可以尝试在 ArcGIS 软件中手动使用相同的 shp 文件执行裁剪操作,看是否能正常工作。

    3. 数据格式问题:验证输入路径中的所有 tif 文件是否具有与 ArcGIS 兼容的有效格式。确保这些 tif 文件可以在 ArcGIS 软件中打开和处理。

    4. 文件权限问题:检查输入路径和输出路径以及 shp 路径中的文件权限,并确保你有足够的权限读取输入文件并写入输出文件。

    5. ArcGIS 版本问题:确认你使用的 ArcGIS 版本与你在代码中指定的版本一致。如果你的版本不同,需要相应地更新代码中的路径。

    6. Traceback 信息:请提供完整的 Traceback 信息,因为它可能包含有关其他潜在问题的详细信息。

    请尝试检查这些方面,并提供更多信息以便更好地帮助你解决问题。

  7. User

    Traceback (most recent call last): File "f:/tif/py/maskby.py", line 42, in out_extract = ExtractByMask(ras, mask) # 鎵ц鎸夋帺妯℃彁鍙栨搷浣? File "D:\arcgis10.5\Desktop10.5\ArcPy\arcpy\sa\Functions.py", line 7201, in ExtractByMask in_mask_data) File "D:\arcgis10.5\Desktop10.5\ArcPy\arcpy\sa\Utils.py", line 53, in swapper
    result = wrapper(*args, **kwargs) File "D:\arcgis10.5\Desktop10.5\ArcPy\arcpy\sa\Functions.py", line 7197, in Wrapper out_raster) File "D:\arcgis10.5\Desktop10.5\ArcPy\arcpy\geoprocessing_base.py", line 510, in return lambda *args: val(*gp_fixargs(args, True)) arcgisscripting.ExecuteError: ERROR 999999: Error executing function. Failed to execute (ExtractByMask).

  8. Assistant

    根据提供的 Traceback 信息,看起来问题出在执行 ExtractByMask 函数时出现了错误。具体的错误信息是 "ERROR 999999: Error executing function"。这个错误通常是由于一些数据格式、权限或其它配置问题导致的。以下是一些可能的解决方法:

    1. 检查输入数据的格式:确保输入的栅格数据集(ras)和掩膜数据集(mask)都是 ArcGIS 支持的格式,比如 GeoTIFF 或 GRID 等。

    2. 检查数据路径和文件名:确保输入的数据路径和文件名都是正确的,并且文件存在于指定的路径中。

    3. 检查文件权限:确保你有足够的权限读取输入文件和写入输出文件。可以尝试将输入和输出路径都设置为你有完全访问权限的文件夹。

    4. 检查 ArcGIS 版本和软件配置:确认你使用的 ArcGIS 版本与你在代码中指定的版本一致,并检查 ArcGIS 软件的配置是否正确。

    5. 尝试在 ArcGIS 软件中手动执行裁剪操作:使用相同的输入数据和掩膜,在 ArcGIS 软件中手动执行裁剪操作,看是否会出现任何错误或警告信息。这可以帮助你确定是否是代码本身的问题。

    如果以上方法都无法解决问题,请提供更多的上下文信息,例如输入数据的实际格式、栅格数据集和掩膜数据集的文件路径,以及 ArcGIS 的版本号等,以便我们可以更准确地帮助你解决问题。

  9. User

    arcpy权限怎么设置

  10. Assistant

    要设置 arcpy 的权限,你需要确保你有足够的权限执行 arcpy 的操作。以下是一些方法:

    1. 管理员权限:确保你以管理员身份运行你的 Python 脚本。在 Windows 上,右键单击你的脚本并选择“以管理员身份运行”。

    2. 文件夹权限:确保你有读取和写入相关文件夹的权限。对于输入和输出文件夹,检查其属性并确保你有合适的权限。

    3. ArcGIS 软件权限:如果你正在使用 ArcGIS 软件,则需要具备 ArcGIS 的相关权限。这意味着你的用户账户必须具有 ArcGIS 软件所需的许可证,并且被授予执行 arcpy 操作所需的权限。

    4. ArcGIS 提供的工具权限:某些 arcpy 工具可能需要特定的许可证或额外的权限。确保你具备执行所需工具的权限。

    请注意,如果你是在 ArcGIS 的 Python 控制台中运行脚本,则前面提到的权限设置通常已经满足,因为你已经在 ArcGIS 环境中。

    如果你仍然遇到 arcpy 的权限问题,建议联系你的系统管理员或 ArcGIS 管理员,以获取更专业的支持和帮助,确保你具备执行 arcpy 操作所需的所有权限。

  11. User

    vscdoe arcpy 权限设置

  12. Assistant

    在 Visual Studio Code(VSC)中设置 arcpy 的权限与其他环境设置方法相似。你需要确保以管理员身份运行 VSC,并且具备合适的权限执行 arcpy 操作。以下是一些方法:

    1. 以管理员身份运行 VSC:在 Windows 上,右键单击 Visual Studio Code 的快捷方式,然后选择“以管理员身份运行”来启动 VSC。

    2. 设置脚本的文件夹权限:确保你对输入和输出文件夹具有读取和写入权限。右键单击这些文件夹,选择“属性”并进入“安全”选项卡,然后检查你的用户账户是否具备合