0

I am writing a very simple code in ArcMap. but it does not run correctly. I want to put a majority filter on my input raster, then use fill tool and then subtract the filled one from the last one and then reclassify the result. the problem is that when I run the code line by line, It works but when I want to run all the code together, I see a bug before "Fill" line. anybody knows what is the problem?

import arcpy

from arcpy import env

env.workspace = r'C:\Users\Arsalan\Documents\ArcGIS'

import arcpy.sa

from arcpy.sa import *

MajorityFilter("Meet_Raster", "EIGHT", "MAJORITY")

MajorityFilter("Meet_Raster", "EIGHT", "MAJORITY")

MajOut = MajorityFilter("Meet_Raster", "EIGHT", "MAJORITY")

arcpy.CheckOutExtension("Spatial")

Fill("MajOut", 12)

FillOut = Fill("MajOut", 12)

RastCalc = Raster("FillOut") - Raster("MajOut")

RastReclass = Reclassify("RastCalc", "Value", RemapRange([[0,0,"NODATA"],[1,3,1],[4,9,2],[9,15,3]]))
  • What error message do you get? – BERA Apr 4 '17 at 7:04
2

I did not test, but I can see two issues:

  • why do you duplicate your lines ?
  • when you store a result in a variable, you should not call this variable as a text. For instance, it should be Fill(Majout, 12)

As a remark, at the end of this process, you will need a "save" to write the final output.

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.