0

I don't know what I'm doing wrong. I always get the error 000865 when using arcpy.ASCIIToRaster_conversion. I'm new and do not have much Python experience right now – so sorry for that.

>>> import arcpy
import os
from arcpy import env
env.workspace = r"D:\Julia_T\projekt\erste_schritte\dritter_tag_python\testdaten"
#folder to list
ascFileList = arcpy.ListFiles("*.asc")
for ascFile in ascFileList:
# geoprocessing steps
ascFileName = os.path.splitext(ascFile)[0]
# define the output file
rastFile = ascFileName + "_output.img"
# run the tool
arcpy.ASCIIToRaster_conversion(ascFile,rastFile, "INTEGER")

Runtime error Traceback (most recent call last): File "", line 15, in File "c:\programme\arcgis\desktop10.2\arcpy\arcpy\conversion.py", line 2193, in ASCIIToRaster raise e ExecuteError: ERROR 000865: Eingabe-ASCII-Raster-Datei: 2001002_cloud_free.asc ist nicht vorhanden.

Do I have to use the CatalogPath? I'm working with ArcMap 10.2.1. Thanks

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Jul 23, 2014 at 13:57
4
  • Well your error is that the raster is not present. Does ` 2001002_cloud_free.asc` actually exist? It is a valid file that is recognized by Arcmap? Commented Jul 23, 2014 at 14:03
  • Take a look here. Could be a weird bug. Commented Jul 23, 2014 at 14:07
  • The steps under the for loop need to be indented -- is it correct in your script? (Often pasting code into Questions loses spaces.) Commented Jul 23, 2014 at 14:09
  • Yes, it in the script. I gonna try to fix it tomorrow. Commented Jul 23, 2014 at 19:31

2 Answers 2

2

The ASCIIToRaster tool is not interpreting the file names correctly, despite you setting the workspace environment. You need to include the full path, so in your case your line should be:

arcpy.ASCIIToRaster_conversion(env.workspace + "\\" + ascFile, env.workspace + "\\" + rastFile, "INTEGER")

Also as @Erica says you should get into the habit of placing print statements in your code to see the actual value of the variables.

answered Jul 23, 2014 at 14:13
0
1

Check whether the raster exists by using a print statement, e.g.

for ascFile in ascFileList:
 print ascFile

If that prints a list of .asc files, try rebooting.

If that doesn't work, check that the ASCII file will convert properly by testing just one (in a separate temporary script).

import arcpy
arcpy.ASCIIToRaster_conversion(r"c:\temp2001002円_cloud_free.asc",r"c:\temp\outp‌​ut.img", "INTEGER")

And use the full file path as Hornbydd describes:

for ascFile in ascFileList:
 # define the input file path
 ascFilePath = env.workspace + "\\" + ascFile
 # define the output file
 ascFileName = os.path.splitext(ascFile)[0]
 rastFilePath = env.workspace + "\\" + ascFileName + "_output.img"
 # run the tool
 arcpy.ASCIIToRaster_conversion(ascFile,rastFile, "INTEGER")
answered Jul 23, 2014 at 14:08
8
  • So I print every step, did restarted the system, but I still get the same ERROR while running the tool. I really don't know what to do. Commented Jul 24, 2014 at 8:03
  • 'print ascFileList #works for ascFile in ascFileList: # geoprocessing steps ascFileName = os.path.splitext (ascFile)[0] print ascFileName #works rastFile = ascFileName + "_output.img" print rastFile #works #run the tool arcpy.ASCIIToRaster_conversion (ascFile, rastFile, "INTEGER") #ERROR 000865' Commented Jul 24, 2014 at 8:11
  • @Nora Try (in a new script, perhaps) running the tool on just one raster with explicit declaration, e.g.: arcpy.ASCIIToRaster_conversion(r"c:\temp2001002円_cloud_free.asc",r"c:\temp\output.img", "INTEGER") Commented Jul 24, 2014 at 11:05
  • it works with just one: ASCII inASCII = r"D:\Julia_T2000067円_cloud_free.asc" outRaster = r"D:\Julia_T\output" rasterType = "INTEGER" arcpy.ASCIIToRaster_conversion(inASCII,outRaster,rasterType) Commented Jul 24, 2014 at 12:40
  • Good, so the raster files are not the problem. Try using the full path as Hornbydd proposes in his answer. Commented Jul 24, 2014 at 12:43

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.