0

The code that "copy as python command" copies:

output_raster = arcpy.ia.RasterCalculator('Con(IsNull("OMUVBd_003_UVindex_Layer1"), FocalStatistics("OMUVBd_003_UVindex_Layer1", NbrRectangle(25,25, "CELL"), "MEAN"), "OMUVBd_003_UVindex_Layer")'); output_raster.save(r"c:\Users\custom pc\documents\ArcGIS\Projects\srp\srp.gdb\onedayinterpolation12")

What it actually is doing: Using Con and isNull and NbrRectangle to interpolate null values. I'm also going to attempt something similar with just turning null values into 0. Both of these are simple in the RasterCalculator, and yet I can't turn this into code, which I need to do 5000 times, so I'm a bit lost. I got RasterCalculator to work with simple arithmetic (an average), but in making the expression I'm completely lost, as 'Con(IsNull("OMUVBd_003_UVindex_Layer1"), FocalStatistics("OMUVBd_003_UVindex_Layer1", NbrRectangle(25,25, "CELL"), "MEAN"), "OMUVBd_003_UVindex_Layer")' doesn't work and neither does the same where all file names are replaced with x, which is preceded by the rasters field being [name of raster in string] and input_names field being ["x"].

I'm not really looking for a different solution to my problem, although I will take that if necessary. Ideally, I will just figure out how to use Con(isNull()). Also, https://pro.arcgis.com/en/pro-app/latest/tool-reference/spatial-analyst/con-.htm suggests that Con is its own function, which confuses me even more and I really need some guiud

3
  • Try breaking it down into steps in your ArcGIS python console, produce an intermediate at each step then when you're happy with doing it the long way expand the calculation again by replacing the temporary names with their generating command. Multiple inline commands are very hard to read, breaking it down to simpler steps will help you find where you've made a mistake; this applies to Excel and OpenOffice Calc also. Commented Feb 1, 2023 at 6:59
  • 1
    Statements like, "XYZ doesn't work," aren't very helpful. What do you mean by "doesn't work?" Does it give an error, then what error (and provide the trackback too). Does it give an unexpected result, if so then state what it gives and what you expect.
    – bixb0012
    Commented Feb 1, 2023 at 15:24
  • bixb0012 -- Sorry, I was fueled by frustration, the code that corresponded to the raster calculation just didn't have 2 of the parameters and errored out. It seemed to only have the expression (the arguably most important part) but the formatting for that was inconsistent with the correct formatting to the point that I didn't know how to tweak it. Michael Stimson -- Thank you. I think part of the problem is I didn't really understand what the actual calculation was doing, it was just working when I put it into the tool. After looking into it further, I only need the Con function. Commented Feb 2, 2023 at 5:40

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.