Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a model which at one point uses the Extract by Attributes tool to produce a new raster with just the areas containing the maximum values of the first.

I would think that the SQL expression would go something like:

"VALUE" = (SELECT MAX("VALUE") FROM in_raster)

No matter what combination I try of expression it always comes up invalid.

I always have to run the model up to the point of this tool, then GET UNIQUE VALUES by hand in the sql builder window to input something like

"VALUE" = some_number

Then it works fine. The rest of the model runs and I get the correct output.

I did try with Zonal stats but the output at the end of the model is not correct when I do.

Is there a way of automating this perhaps with some python or another set of tools?

I have a number of initial values I need to iterate through for this model and I want the whole thing to be able to run without me having to do that step manually.

Thanks in advance

share|improve this question
add comment

2 Answers 2

If you run Zonal Stats (max) this will "fill" your zone with that maximum value. In a second step you will then need to ask the raster calculator: Where is the Zonal stat grid equal to the original grid? Or something like:

[zonal_out] = in_raster

This will give you the pixels with the max values as calculated from the zonal stats tool.

share|improve this answer
add comment

I'm not sure how this could be done in ModelBuilder without creating an intermediate raster or zonal layer as was suggested. However, it is pretty straightforward in python. Maybe there is some way to add a python script into the ModelBuilder flow. I haven't done that before, so I can't say. Here is an example of how the two steps would be carried out in the python window:

whereclause = "VALUE = " + str(arcpy.GetRasterProperties_management("C:/path_to_rasters/in_raster", "MAXIMUM"))
out_raster = arcpy.sa.ExtractByAttributes("C:/path_to_rasters/in_raster", whereclause)
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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