Pixel/cell count within a raster map

14543
8
Jump to solution
03-09-2012 04:28 AM
PeterNilsson
Emerging Contributor
Hello!

I'm a Swedish student styding a beginners course in GIS and I have a question. I'm working with a raster map and want to count the numbers of pixels/cells within an area in the map (a lake). Is this possible? The purpose is to calculate the area of the lake and I dont want to use the measure tool because the map isn't exactly projected.

I would appreciate support!

Best regards

Peter Nilsson
0 Kudos
1 Solution

Accepted Solutions
JeffreySwain
Esri Regular Contributor
Zonal Statistics as a table can count the number of pixels that fall within the feature.  However, you should still project the lake (polygon) and the raster to the same coordinate system and be sure they overlap.

View solution in original post

0 Kudos
8 Replies
JeffreySwain
Esri Regular Contributor
Zonal Statistics as a table can count the number of pixels that fall within the feature.  However, you should still project the lake (polygon) and the raster to the same coordinate system and be sure they overlap.
0 Kudos
PeterNilsson
Emerging Contributor
Hi Jeff!

Thanks for your answer och tip! However I didn´t managed to count all pixels within the lakes border. The lake is not a polygon but a part of the raster map. But perhaps you ment that I should convert to polygon? I would like a tool how can delimit an area within a raster map and count the number of pixels within the area. In that case I'll could manually draw a line around the lake and get the the number of pixels as an outcome. Is there a tool like that or is there even a better way to accomplish my objective? I haven't worked with raster that much.

/Peter
0 Kudos
JeffreySwain
Esri Regular Contributor
If the lake is one value you could extract that portion of the raster by attribute and then make that particular raster the 'zone.'  In the Zonal statistics tool, you can use a raster as long as it is an integer and the values for the zone are homogenous. 

There is not just a simple tool you can freehand a graphic and any created tool like that will likely contain the same tools mentioned above.
0 Kudos
PeterNilsson
Emerging Contributor
There are several different values within the lake so I guess its impossible. Thanks anyway!
0 Kudos
GeospatialTechnology
Deactivated User
Just an idea but couldnt you convert raster to polygon. Then dissolve all the polygons that make up the lake into one polygon and then use that as the feature in zonal statistics?
0 Kudos
PeterNilsson
Emerging Contributor
Thanks for the tip yppmark! However, I haven't been able to convert the raster into polygon, I only get a message saying "error 999999".
0 Kudos
JeffreySwain
Esri Regular Contributor
Have you performed any generalization to clean up the raster prior to converting it to polygons?  Many of the outputs from the conversion are not what is intended if the raster is too variable, you create a lot of small polygons, which end up being more problematic than the original raster.  Be sure to create a feature class instead of a shapefile to avoid the size limitation of a shapefile.  I would recommend trying a subset of the raster and also trying some of the generalization tools to clean up the edges or perhaps reclass the raster into definitive areas prior to conversion.
0 Kudos
PeterNilsson
Emerging Contributor
No I haven't done any generalization, thanks for the tip, I will try this when I have time.
0 Kudos