ERROR 000865: Input ASCII raster file: 299_327_Intensity.asc does not exist.

2863
7
04-12-2011 07:26 PM
CraigMason
New Contributor
Hi everyone,
I built a model in model builder to clip one raster by another raster and return the area of the intersection.
It works fine in model builder but I need to add the model to some other code I am working on.
When I run the exported python script I get this error:

ERROR 000865: Input ASCII raster file: 299_327_Intensity.asc does not exist.
Failed to execute (ASCIIToRaster).

associated with this line of code:

    gp.ASCIIToRaster_conversion(Asc_Intens, Intensity1, "INTEGER")

The variable Asc_Intens points to the file "299_327_Intensity.asc" which certainly does exist.

Can anyone please tell me what is going on?
Kind Regards,
Craig Mason.
0 Kudos
7 Replies
DarinaTchountcheva
Occasional Contributor II
Craig,

I had a similar error while creating a raster, and the problem was that my raster file name was longer than 13 characters.

I was using a different tool but this might be your problem too.

Good Luck!

Darina
0 Kudos
curtvprice
MVP Esteemed Contributor
It's also kind of dangerous to name datasets or fields anywhere in arcgis that start with a number.
0 Kudos
DustinEdge
Occasional Contributor
Hi there

I had the same problem. I tried using short filenames and even short folder paths, but nothing worked.

In the end, I got it to work using the CatalogPath as the input variable.

import arcgisscripting, string, os, sys
gp = arcgisscripting.create(9.3)

gp.Workspace = r"U:\GIS\Temp"
ascList = gp.ListRasters("*.asc", "*")


for ascFile in ascList:
    dsc = gp.Describe(ascFile)          # Gets the Description about the ascii file
    ascIn = dsc.CatalogPath             # Gets the Full Catalog Path of the ascii file
    ascOut = ascIn[:-4] + ".img"        # Removes the .asc extension and adds .img
    gp.ASCIIToRaster_conversion(ascIn, ascOut, "FLOAT")
0 Kudos
curtvprice
MVP Esteemed Contributor
I'm wondering if that was a pathname issue.

BTW the best way to strip off the extension is to use the python os module. This will work even if the input file name doesn't include an extension:

import os
ascOut = os.path.splitext(ascIn)[0] + ".img"
0 Kudos
CraigMason
New Contributor
Hi Guys,
Thanks for all your help. It was a pathname issue and I seem to have solved it... for now!!
Thanks again,
Craig.
0 Kudos
MattWootton
New Contributor II
Hi Craig,
Getting the same error.  Have a script that runs fine when using a single .asc as input but I get the "does not exist error" when I use the ListFiles option.  Can you post the line(s) of your script that worked please?
0 Kudos
curtvprice
MVP Esteemed Contributor

ArcGIS doesn't see .asc files as files, they are recognized as raster datasets. arcpy.ListRasters() would have worked in this case.

0 Kudos