0

I failed to calculate the Euclidean distance with the EucDistance function in the PyCharm. The codes are as follows.

import arcpy
from arcpy import env
from arcpy.sa import *
arcpy.env.overwriteOutput = True
env.workspace = "D:/Study/Reference/ecological integrity/regions"
outEucDistance = EucDistance("Highways1.tif", "", 30, "")
outEucDistance.save("D:/Study/Reference/ecological integrity/ED.tif")

Now, I received the following warning message

Traceback (most recent call last): File "D:/Software/11.py", line 9, in outEucDistance = EucDistance("Highways1.tif", "", 30,"") File "d:\Program Files\ArcGIS 10.4\Desktop10.4\arcpy\arcpy\sa\Functions.py", line 968, in EucDistance out_direction_raster) File "d:\Program Files\ArcGIS 10.4\Desktop10.4\arcpy\arcpy\sa\Utils.py", line 53, in swapper result = wrapper(*args, **kwargs) File "d:\Program Files\ArcGIS 10.4\Desktop10.4\arcpy\arcpy\sa\Functions.py", line 962, in Wrapper out_direction_raster) File "d:\Program Files\ArcGIS 10.4\Desktop10.4\arcpy\arcpy\geoprocessing_base.py", line 506, in return lambda *args: val(*gp_fixargs(args, True)) arcgisscripting.ExecuteError: ERROR 010429: GRID IO 中存在错误: GetOpenTileChannel: Could not create tile. name: d:\study\reference\ecological integrity\regions\xx0025560000, adepth: 32, type: 1, iomode: 1, version: 3, compression: 0, eval case: 1 。 ERROR 010296: 写入栅格 d:\study\reference\ecological integrity\regions\xx0025560000 时出错。 Distance mapping is failed ERROR 010067: 执行格网表达式时出错。 执行(EucDistance)失败。

The data is here.

How can I fix this?

2
  • Your code does not match the error. Are you actually setting env.workspace = "D:/study/reference/ecological integrity/regions"...? A search of the error reveals the answer
    – user2856
    Commented Jun 20, 2023 at 10:36
  • Thank you!I just edited the codes to match the warnings. This error is due to the spaces in my name of directory (i.e., ecological integrity). If it is named as "ecological_integrity", this error will be addressed.
    – zongxu li
    Commented Jun 20, 2023 at 11:57

2 Answers 2

1

The correct code is

import arcpy
from arcpy import env
from arcpy.sa import *
arcpy.env.overwriteOutput = True
env.workspace = "D:/Study/Reference/ecological_integrity/regions"
outEucDistance = EucDistance("Highways1.tif", "", 30, "")
outEucDistance.save("D:/Study/Reference/ecological_integrity/ED.tif")

The spaces in the name of directory are not permitted. Please refer to this.

0

Another way to get this to work without having to rename your folders is as follows:

import arcpy
from arcpy import env
from arcpy.sa import *
arcpy.env.overwriteOutput = True
env.workspace = r"D:/Study/Reference/ecological integrity/regions"
outEucDistance = EucDistance("Highways1.tif", "", 30, "")
outEucDistance.save(r"D:/Study/Reference/ecological integrity/ED.tif")

The r prefix will convert the path text to a raw string.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.