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:
-
SELECT MAX(TABLE_COLUMN) from SCHEMA.TABLENAME (works on Oracle)Mapperz– Mapperz ♦2019年05月21日 18:58:53 +00:00Commented 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?Jared– Jared2019年05月21日 19:05:57 +00:00Commented May 21, 2019 at 19:05
-
for your raster maximum value can be found using 'Cell Statistics' gis.stackexchange.com/questions/65747/…Mapperz– Mapperz ♦2019年05月21日 19:28:38 +00:00Commented 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?Jared– Jared2019年05月21日 19:41:47 +00:00Commented May 21, 2019 at 19:41
1 Answer 1
This is the model that you are seeking:
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%
.
-
Thank you very much! I'm surprised it requires so many steps, and I never would have thought to do this on my own.Jared– Jared2019年05月21日 22:00:48 +00:00Commented 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.Hornbydd– Hornbydd2019年05月22日 09:17:44 +00:00Commented May 22, 2019 at 9:17
Explore related questions
See similar questions with these tags.