I have a map with about 63 grids and trying to determine the land cover user category of the greatest area size in each grid. The land cover categories have been converted to polygons and I already have attribute tables with a field for "Area" in each grid. I need to create a layer that will give me which land use category has the greatest area size. So I need to sum up the "area" of each category and then determine the max (highest area) and then make a layer for only that category.

i.e. Grid 1 contains - water = 900m, development = 1000m, forest = 2000m Grid 1 - category with highest area size = forest at 2000m - I would need just one layer displaying forest only in that grid. But then do this quickly for all other grids in my map.

I am a mid-level user in ArcMap with decent SQL query skills, so I feel most comfortable in SQL and I'm certain a making a query with a join statement that joins onto itself can get that done for me. I'm looking where/how best to run a SQL query that will be a little more complex than the regular "select * from". Looking at tools like the "Select attribute by" is nice but the SQL query section in there doesn't really allow for inner join statements to be performed. Or if all this needs to be done a different way how I go about to create the layers I need. I could of course trudge through each grid and do it manually but I am looking to learn how to do such things in a faster method and use in the future.

Will I be venturing into ArcPy and/or ModelBuilder?

I want to sum up "Area" per "Gridcode" then determine which "Gridcode" has the highest sum area. Then make that into a new layer. I would not need any other gridcodes if they do not sum up as the max.



1 Answer 1


If I am understanding you right you started out with an NLCD raster and a polygon feature class of your grids. You then converted the raster to polygon within each of your grids cells to yield polygons with the corresponding NLCD land cover class.

Spatial Analyst Approach: I would redesign your workflow as follows: Before converting to polygons I recommend using the Zonal Statistics tool on the original NLCD, with your zones being the grid polygons and the NLCD land cover class being the value. You set the statistics field to be 'MAJORITY'. You then use the Raster Calculator tool to convert anything that is not of the majority land cover class to no data.

SetNull([NLCD]<>[zonalstat], [zonalstat])

What remains will be a raster of only the majority land cover. You could similarly use the Reclass tool. Then you can do your conversion to polygon, the resulting polygons will have the only majority land cover. You should note however that if more than one land cover class has the same number of cells only one will be returned by this procedure. So you may want to do Zonal Statistics as Table to find grids that have more than one land cover in the majority status.

SQL approach: For an SQL based approach on your area polygons, you can try the Make Query Table tool if you have a geodabase. I have never used it so I do not know how powerful it is. Your SQL you would be something like this:

SELECT grid_id, land_use_class, max(area) OVER (PARTITION BY area) 
FROM table
WHERE area = max(area)

You can take a look at the Window Functions documentation for PostgreSQL for more detail.

But you may want to check that your polygons did not get split, for example by an area of different land cover in between two areas of the same land cover. You need to make multipolygons when you convert from raster, otherwise your dominant land cover could be masked because the dominant is not contiguous.

  • Thayer, thank you so much!! I think that did the trick. I did an initial test of using Zonal Stats and it is looking good. I will do a full run through on my real data today and I am confident this is what I needed. I was so focused on getting it done via SQL and with the end product polygons that I already had that I didn't think much to go back to my Rasters and work with them using the Zonal stats. Once again thanks!
    – Vance
    May 24, 2016 at 12:47
  • I think the SQL will be too complicated for Arc for desktop. I am not sure you can do full queries without Arc SDE. I mostly work in PostGIS now which is based on PostgreSQL, you would need something like: SELECT max(area) OVER (PARTITION BY grid_id) FROM table WHERE area = max(area)
    – thayer
    May 24, 2016 at 14:41
  • I do a lot work in SQL for other non-GIS work so that is what I am comfortable and that is why I sought it out. Bummer that SQL is so limited in the basic version of ArcMap. I just have a trial version of Arc loaded on my desktop as stand alone. Are there any options for me to use ArcSDE/PostGIS/PostgreSQL? Or will those cost me money? Not sure if I need an entire database structure to link to to make that all happen.
    – Vance
    May 25, 2016 at 14:02
  • PostgreSQL and its PostGIS extension are free and open source. I think I was wrong, it does appear that you can connect to several spatial databases with the standard ArcGIS for Desktop, you have to download some linker software see this help document: resources.arcgis.com/en/help/main/10.2/index.html#/…
    – thayer
    May 26, 2016 at 20:45
  • It looks like you can do full queries using Make Query Table, having never used it I do not know how powerful it is, see this help page: resources.arcgis.com/en/help/main/10.1/index.html#//…
    – thayer
    May 26, 2016 at 21:04

Your Answer

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

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