0

I currently have a raster that has 3 columns in the attribute table: OBJECTID, Value, and Count. As part of ModelBuilder, I am running this raster through the Extract by Attributes tool. The Extract by Attributes tool requires an SQL Where clause. I can't seem to figure out how to write something that will simply select the highest/maximum Count value.

I have tried MAX(Count), SELECT MAX(Count), "MAX(Count)", and many others. I checked the documentation page tool, but didn't find anything that helped.

The error I am getting most of the time:

enter image description here

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked May 21, 2019 at 18:41
4
  • SELECT MAX(TABLE_COLUMN) from SCHEMA.TABLENAME (works on Oracle) Commented May 21, 2019 at 18:58
  • Can you please elaborate? How do I find the schema/tablename? Is it not the same as the raster name? Commented May 21, 2019 at 19:05
  • for your raster maximum value can be found using 'Cell Statistics' gis.stackexchange.com/questions/65747/… Commented May 21, 2019 at 19:28
  • @Mapperz How can I use the output from Cell Statistics as an input for the Extract by Attributes tool? Commented May 21, 2019 at 19:41

1 Answer 1

5

This is the model that you are seeking:

Model

You create the table view of the raster, sort that into an in-memory table, then use the Get field value which only every looks at the first row which is your sorted data by count and then the extract by attribute is an SQL clause Count = %MAX_Value%.

answered May 21, 2019 at 19:53
2
  • Thank you very much! I'm surprised it requires so many steps, and I never would have thought to do this on my own. Commented May 21, 2019 at 22:00
  • I agree it does seem an unnecessary number of steps but even if you coded this in python you would still need to loop the entire table to identify the maximum value in the count field. Commented May 22, 2019 at 9:17

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.