Combine Tool Fails in Arcpy but not in Model Builder

994
3
07-02-2013 09:54 AM
JiaxinYu
New Contributor
Hello,

I have a model builder tool that uses the Combine tool in one of the steps, and have increased the maximum number of unique values to render in the ArcCatalog and ArcMap's Raster Dataset option to accommodate the number of unique value. The tool works. However, when I trying to call the combine tool with the same inputs in arcpy, it is not recognizing the setting, and would give the following error message: "ExecuteError: ERROR 999999: Error executing function. ("esriDataSourcesRaster.RasterCalcUniqueValues") Too many unique values".

I am using 10.1, are there modules and environmental setting that I should be calling to resolve the issue?

Thank you all!
J-

The codes runs right up to the combine step.


import arcpy, os, sys
from arcpy import env
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial")


env.overwriteOutput = "True"


##RegionFile= arcpy.GetParameterAsText(0)
RegionFile = r'C:\Temp\RegionFile.csv'

#constant input
inBFE = r'C:\Work\SDE_Connections_us\SV2_FEMA.sde\FEMA.FEMA.Polyline_01_16_13\FEMA.FEMA.BFE_01_16_13'
NED30M = r'\\rsarcsv3\Model_08\ArcSDE\SDE_Connections\SV2_NED_30m.sde\NED_30m.NED_30M.NED_30M'



rows = arcpy.SearchCursor(RegionFile, "", "", "Region", "")
currentRegion = ""
for row in rows:
        currentRegion = row.Region
        print currentRegion
        
        MF = r'C:\Work\Flowlines'
        fGDB = arcpy.CreateFileGDB_management(r'C:\Temp', "R" + currentRegion, "CURRENT")
        env.workspace = fGDB
##        fGDB = r'C:\Temp\R.gdb'
        #outputnames
        outClipBFE = str(fGDB) + "\clipBFE" 
        outIntersetBFE_MF = str(fGDB) + "\BFE_MF_Intersect"
        outpt2Ras = str(fGDB) + "\BFE_MF_Pt2Ras"
        outint100yr = str(fGDB) + "\int100yr"
        outintNED30 = str(fGDB) + "\intNED20"
        outCombine = str(fGDB) + "\combineBFE_NED"

        
        twentyoneLyrFolder = r'C:\Work\21Layers'
        airFldMap = twentyoneLyrFolder + "\Region" + currentRegion + "\wl_R" + currentRegion + "_tif_09.tif"
        
        regionBND = "C:\Work\BOUNDARY" + currentRegion + "_BuffClip"

        #Environment
        env.cellSize = FldMap
        env.extent = FldMap
        env.snapRaster = NED30M
       
        clipBFE = arcpy.Clip_analysis(inBFE, regionBND, outClipBFE)
        intersectBFE_MF = arcpy.Intersect_analysis([clipBFE, MF], outIntersetBFE_MF, "ALL", "", "POINT")
        pt2Ras = arcpy.PointToRaster_conversion(outIntersetBFE_MF, "OBJECTID", outpt2Ras, "MOST_FREQUENT", "NONE", "30")

        #multiplying raster by 1000
        int100yr = (SetNull(airFldMap <= -9999, FldMap))* 1000
        int100yr.save(outint100yr)
 
        intNED30 = Raster(NED30M) * 1000
        intNED30.save(outintNED30) 
        
        #combine Rasters
        combineBFE_NED= Combine([outpt2Ras, outintNED30, outint100yr])
        combineBFE_NED.save(outCombine)
Tags (2)
0 Kudos
3 Replies
RhettZufelt
MVP Notable Contributor
I see this in the help:

For formats other than ESRI GRID, by default, the output raster from this tool can only have a maximum of 65536 unique values.

You can increase this number by changing a setting in ArcGIS. On the Main menu, select Customize > ArcMap Options. In the ArcMap Options dialog box, click on the Raster tab and modify the Maximum number of unique values to render field to an appropriate value.



Don't know a way to change these settings for arcpy (perhaps a tech support question), however, based on the help documentation, it appears as if the ESRI GRID format is not held to this contraint.

Perhaps you could output as GRID to get the results you are after?

R_
0 Kudos
JiaxinYu
New Contributor
Hello Rhett,

I read the same thing, and did exactly that and it does work when running process in ArcMap and ArcCatalog both foreground and in the background. Also, all my rasters are in GRID format. For some unknown reason, when I put it into arcpy, it's not recognizing the setting, and I'm not able to find any syntax that would let me hard code it in there.
0 Kudos
RhettZufelt
MVP Notable Contributor
I see you have already changed the "settings" in ArcMapCatalog so that explains why it is working within them. However, don't think there is a way for arcpy to inherit these settings, so I'd try the GRID output format and see if that works in standalone arcpy.

It looks as if you are including your FGDB path in your save path so that they are saved within a FGDB. this will force them to be FGDB feature classes/tables/rasters, etc. and not GRID format

If you code it to save in a folder (not FGDB) and leave off the file extention, it should create them as GRID format and "supposedly" not have the 16bit restriction.

Not sure if you would just have to have combineBFE_NED as a GRID since that is the output, or if you would have to use GRID's for input as well. Would have to test.

R_

also, not sure if you've fixed it already (or if it is intentional) but this doesn't quite look right:

outintNED30 = str(fGDB) + "\intNED20"

to be consistant with your other variables, should this be

outintNED30 = str(fGDB) + "\intNED30"
0 Kudos