Select to view content in your preferred language

ASCIIToRaster_conversion Error 010328 and 010267

Jump to solution
01-25-2019 01:06 PM
New Contributor II

Here is a program that worked well six months ago doing the same thing but refuses to do so now and returns the error messages. Any advice would be appreciated.

import arcpy, os, glob, shutil, fnmatch
from arcpy import env
from import *
import time
start_time = time.time()
env.overwriteOutput = True
# Set environment
arcpy.env.workspace = "G:/GIS Data/FAO GAEZ/low irrigation"
arcpy.env.scratchWorkspace="G:/GIS Data/scratch"

# Set local variables
# folder containing only input rasters and nothing else
inws = "G:/GIS Data/FAO GAEZ/low irrigation"
outws="G:/GIS Data/FAO GAEZ/rasters/World/low_irrigation"

for root, dirs, files in os.walk(inws):
 for subdir in dirs:
 print subdir
 print directory
 print outRaster
 print asciiname
 if not os.path.exists(directory):
print "Done"

Here are the results. I should note that the program is creating the directory successfully. Line 37 refers to the arcpy.ASCIIToRaster...command.

G:/GIS Data/FAO GAEZ/rasters/World/low_irrigation/chickpea_105_low
G:/GIS Data/FAO GAEZ/rasters/World/low_irrigation/chickpea_105_low/data
G:/GIS Data/FAO GAEZ/low irrigation/chickpea_105_low/data.asc

Traceback (most recent call last):
File "C:\Users\achanda\Dropbox\Research\India Canals\python\", line 37, in <module>
File "C:\Program Files (x86)\ArcGIS\Desktop10.6\ArcPy\arcpy\", line 2461, in ASCIIToRaster
raise e
ExecuteError: ERROR 010328: Syntax error at or near symbol SPACE.
ERROR 010267: Syntax error in parsing grid expression.
Failed to execute (ASCIIToRaster).

0 Kudos
1 Solution

Accepted Solutions
MVP Honored Contributor

Can you try saving to a directory that contains no spaces, just to rule that out?

View solution in original post

4 Replies
MVP Honored Contributor

Can you try saving to a directory that contains no spaces, just to rule that out?

MVP Emeritus

line numbers and formatting /blogs/dan_patterson/2016/08/14/script-formatting 

for future reference

And I would recommend saving to *.tif raster format, in a folder.  tifs behave better than the old esri grid format since they have fewer restrictions on how they are named

New Contributor II

Thanks for your replies. It was definitely the long directory name with spaces. I really need to address that.

Dan, thanks for directing me to those instructions as well.

0 Kudos