2

I am attempting to create in ArcGIS 10.3 a Modelbuilder code based partially on that in Using raster calculator in ModelBuilder to batch reclassify hundreds of rasters? My code will run through 70+ rasters of different sizes, raster calc them from meters to feet, place them in a specific directory, and eventually iterate both a polygon from raster boundary, two separate contour maps, and add a field and an attribute to each of the polygon boundaries. However, I am encountering a problem in just creating the Raster Calculator iteration.

Here is my Modelbuilder as currently drafted: Modelbuilder Layout

Its code:

# Import arcpy module
import arcpy

# Load required toolboxes
arcpy.ImportToolbox("Model Functions")

# Script arguments
Test_Group = arcpy.GetParameterAsText(0)
if Test_Group == '#' or not Test_Group:
Test_Group = "N:\\Planning And Development\\Engineering\\Systemwide GIS\\Geodatabases\\Comprehensive\\Test Group" # provide a default value if unspecified

# Local variables:
Name = "USGS_NED_one_meter_x46y443_CO_SoPlatteRiver_Lot5_2013_IMG_2015.img"
feet__Name_ = "N:\\Planning And Development\\Engineering\\Systemwide GIS\\Geodatabases\\TestOutput\\feet_%Name%"
Raster = "N:\\Planning And Development\\Engineering\\Systemwide GIS\\Geodatabases\\Comprehensive\\Test Group\\USGS_NED_one_meter_x46y443_CO_SoPlatteRiver_Lot5_2013_IMG_2015.img"
Value = "USGS_NED_one_meter_x46y443_CO_SoPlatteRiver_Lot5_2013_IMG_2015.img"

# Process: Iterate Rasters
arcpy.IterateRasters_mb(Test_Group, "", "", "RECURSIVE")

# Process: Raster Calculator
arcpy.gp.RasterCalculator_sa("\"%Name%\" *  3.28", feet__Name_)

# Process: Parse Path
arcpy.ParsePath_mb(Raster, "FILE")

Here is the Raster Calculator setup (ignore the error message, that was after I ran through an iteration): RasterCalculator

Output comes out like this: B/W output

Strangely if I run an individual instance of Raster Calculator, it comes out in greyscale as normal. However, with 70+ rasters I don't want to do one at a time especially since I want to automate other tasks after I have solved this error.

Where am I going wrong?

  • Have you checked out if the calculated raster values (just one sample each, model builder and manual) are the same? – fatih_dur Sep 10 '16 at 8:08
  • Both the manual and the MB calculations have the same range output. Is there any other way to check the values? – policy_brain Sep 12 '16 at 14:25
  • Here is a picture of the two. Feet_ is the modelbuilder execution, Feet2_ was an independent Raster Calculator session: imgur.com/Wb7t46B – policy_brain Sep 12 '16 at 20:40
1

After your comments, I think your issue is related to not having a histogram to show your raster as desired. If you add Calculate Statistics tool after Raster Calculator output, you should be able to see them rendered correctly.

  • I attempted this, with a CS tool running after RC as recommended, and it produces the same output as without the CS tool. Also, I noticed this interesting characteristic. The input are wildly different sizes, but the input both came out in the same file size: Input Output – policy_brain Sep 13 '16 at 15:08

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.