1

I have a folder with multiple rasters that need to be reclassified. Using spatial analyst reclassify tool, I have the following script:

import arcpy
import pandas as pd
arcpy.CheckOutExtension("Spatial")
from arcpy import env
from arcpy.sa import *
arcpy.env.overwriteOutput = True

# Set environment settings
env.workspace = r"C:\Users\\Documents\ND_files\NASS_CDL"

nrasterList = arcpy.ListDatasets("*","Raster")
     for targetRaster in nrasterList:
     inRaster = targetRaster
     remap = RemapValue(remap1)
     #remap1 is a list of lists ex. [[0,1],[1,3],[44,3]]
     outReclassify = Reclassify(inRaster, "Value", remap, "NODATA")
     # Value is the name of the column to be reclassified
     outReclassify.save(r"C:\Users\Documents\ND_files\NASS_CDL\reclass")

the error I receive:

RuntimeError: ERROR 010240: Could not save raster dataset to C:\Users\Documents\ND_files\NASS_CDL\reclass with output format GRID.

I read somewhere else that people were having issues saving the NASS Crop Data Layer and working with GRID format.

  • Have you tried saving it as a TIFF? – Brian Sep 25 '16 at 15:56
  • 2
    The code looks fine although I don't see where you are assigning the value for remap1? – Brian Sep 25 '16 at 16:03
  • I calculated remap1 from another code on a line above. I didn't realize there was an option to save as a TIFF. I just assumed the raster output would be TIFF. Do I simply do that by adding .tif after the file save name? – dand Sep 25 '16 at 18:21
  • 2
    Yes you just add .tif. Here are all of the supported raster formats when using spatial analyst. If you don't put an extension ArcMap will default to the ESRI Grid type. – Brian Sep 25 '16 at 18:28
  • 1
    If you want to use ESRI GRID, make sure that the name of a grid cannot be stored using spaces, it cannot start with a number, and it cannot be longer than 13 characters. – ahmadhanb Sep 26 '16 at 1:09
1

As noted here you have to specify output raster format:

When you name your output raster dataset, specify:
.bil for Esri BIL,
.bip for Esri BIP,
.bmp for BMP,
.bsq for Esri BSQ,
.dat for ENVI,
.gif for GIF, 
.img for ERDAS IMAGINE,
.jpg for JPEG,
.jp2 for JPEG 2000, 
.png for PNG, 
.tif for TIFF file format,
or no extension for an Esri Grid or a raster dataset in a geodatabase.

You have to check your path. Does it lead to actual Geodatabase?

Also paths in your code are different (note double slashes):

env.workspace =    r"C:\Users\\Documents\ND_files\NASS_CDL"
outReclassify.save(r"C:\Users\Documents\ND_files\NASS_CDL\reclass")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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