[Beginner question] Error when converting raster to ASCII

Benjamin Kaplan benjamin.kaplan at case.edu
Mon Nov 15 11:36:46 EST 2010


On Monday, November 15, 2010, Becky Kern <kern.ra at gmail.com> wrote:
> Hi again users,
>
> This is in response to my post from 11/14/2010 (see below)
>
>> Hi users,
>> I'm using Python 2.5 (in concert with ArcGIS 9.3) to convert a raster to
>> an ASCII file. I used the code (listed below) several weeks ago to
>> successfully do the conversion, but when I tried to replicate it a few
>> days ago, I got an error message.
>> import arcgisscripting
>> gp = arcgisscripting.create(9.3)
>> InRaster = "C:/data/raster1"
>> OutAsciiFile = "C:/data/raster2ascii.asc"
>> gp.RasterToASCII_conversion(InRaster, OutAsciiFile)
>> The error message:
>> arcgisscripting.ExecuteError: Failed to execute. Parameters are not
>> valid. raster1 does not exist.
>> My file path has not changed so I don't understand why Python can no
>> longer recognize my raster file. Any ideas?
>>
>
> MRAB responded:
> Just to make sure, does os.path.isfile(InRaster) return True?
>
> When I tried os.path.isfile(InRaster), I received the following error message:
> "NameError: name 'os' is not defined"

you need to import os.path

>
> Does this shed any light on why my raster to ASCII conversion isn't working?
>
> Thanks again.
>
>



More information about the Python-list mailing list