I have a USA raster dataset, which assigns to each cell a value from 0-100. I also happen to have a USA county shapefile. I simply want a count of the number of pixels/cells in the raster data with values >50 that lie within a county polygon, as given in the county shapefile.

1) How may I go about doing this? Also, how does one deal with cells/pixels that overlap with polygon boundaries?

2) This is my first time using Raster data, so I am not aware of all the intricacies of it. Do I need to be worried about projection stuff etc.? I have a hunch that I do not have to worry about this: Raster properties state that Spatial Reference is GCS_WGS_1984, with angular unit of degrees and Datum D_WGS_1984. The shapefile states the Geo coordinate system to be GCS_WGS_1984, with angular unit of degrees and Datum D_WGS_1984. The raster file, however, does not specify Prime Meridian which is Greenwich for my shapefile.

  • Do you have the Spatial Analyst Extension available to you? Commented Apr 13, 2015 at 15:08
  • @jbchurchill Not on my current pc. I should be able to get access to it. Is this possible both with or without the spatial analyst extension? A description of both with pros/cons will be really helpful.
    – user52932
    Commented Apr 13, 2015 at 15:23
  • I see three questions here. This forum is best suited for a single answerable question. Would it be possible to refine your question to include a single question? Regarding the projection, as a general guideline, you want to convert GCS to projected for most analyses.
    – Aaron
    Commented Apr 13, 2015 at 15:47
  • @Aaron Hm. I am not sure how to do this because I think that all 3 relate to the topic of question. Are you asking me to delete 2 of the questions and ask them separately in different posts?
    – user52932
    Commented Apr 13, 2015 at 16:29
  • It may be tempting to ask multiple questions for your convenience, however, in order to keep the quality of this Q/A site, it is important to keep the questions focused. I can see questions 1 and 2 being lumped together, but the third question is a completely separate topic. Please see these additional references: meta.stackexchange.com/q/39223 and gis.stackexchange.com/help/how-to-ask
    – Aaron
    Commented Apr 13, 2015 at 16:37

3 Answers 3


You can do this in two steps. First, use Con (Spatial Analyst) to convert cells > 50 to 1 and all other cells to 0. Then use Zonal Statistics as Table (Spatial Analyst) to count the number of "1" cells within your polygon.

enter image description here

  • I was thinking of Con as a possibility too but wrote about ReClass which would accomplish pretty much the same thing +/-. Commented Apr 13, 2015 at 15:40
  • Agreed, same results. I personally prefer the Con tool because I like the control of the Con expression.
    – Aaron
    Commented Apr 13, 2015 at 15:43

The only way that I know of to do this, requires spatial Analyst so perhaps I'll write it up as such and if it is possible another way, someone else will write that up as a separate answer. With the Spatial Analyst Extension, the tool to use is Zonal Statistics. I typically use Zonal Statistics As Table.

I typically use a projected coordinate system whenever I do anything of this nature especially if area is important. It may not be entirely necessary to re-project the data to do this (you can certainly try). If it doesn't run well in GCS, then try to re-project and see if that fixes the problem.

The method will count cells within the polygon that includes most of the cell (to answer your question in item 1.

Use the Zonal Statistics As Table Tool with the polygon layer as your zone (select a field that uniquely identifies each polygon as the zone field). The raster is your value layer.

The results will have values for each different category. You have the option of grouping values in the raster first or in the table after (whichever you find easiest). You can use a tool like "Reclass" to reclassify the raster into groups (like your example of >50) or you can certainly do it with the table after running it on the original raster.

ADDED: To address your comment about how zonal stats works and spatial resolution, a good practice is to set your Environment Settings (Raster Analysis Settings specifically). Set the cell size and snap raster to your input! Also to answer your question about boundaries, it converts the polygon to raster first so setting the snap environment helps. The raster will never conform to the shape of the polygon but it will assign values to the zone raster based on the values of the cells using the zone that contains the "majority" of a cell.

(see screenshot)

Since your raster is what it is and your polygon is what it is, this is really the best you can do. The higher the resolution the raster is, the better it will work.

SUM should work as a statistic for you AFTER you run CON or reclass values >50 to 1.

Hope this helps.

  • Thanks. So if I use the Con tool described in the other answer, the SUM statistic will give me the count. Is that correct?
    – user52932
    Commented Apr 13, 2015 at 16:03
  • So according to the GIS help document, Zonal Statistics will internally convert my polygon shapefile to a raster data set and then do this count. So the way I visualize raster data is like a board of checkers. So if Polygons are converted to rasters, how will the boundaries be treated? Will the converted raster be at the same spatial resolution of the original raster?
    – user52932
    Commented Apr 13, 2015 at 16:26
  • See my "ADDED" section above. Commented Apr 13, 2015 at 19:11

SA free approach is 1) convert raster to points, 2) spatial join points to polygons 3) select values greater 50 4) apply summary statistics using polygon id as case field. Could be very slow, depending on raster size

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.